I need to validate the selection of a proper location during PO Receipt, which may mean altering the "Default" location defined on the Item Warehouse screen on an ad hoc basis. My challenge is that the field defaulting event handler is defined within the POLocationAvailAttribute Attribute rather than the POReceiptEntry graph.
public class POLocationAvailAttribute : LocationAvailAttribute
{
public POLocationAvailAttribute(Type InventoryType, Type SubItemType, Type SiteIDType, Type TranType, Type InvtMultType)
: base(InventoryType, SubItemType, SiteIDType, TranType, InvtMultType)
{
}
public override void FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
POReceiptLine row = e.Row as POReceiptLine;
if (row == null) return;
if (POLineType.IsStock(row.LineType) && row.POType != null && row.PONbr != null && row.POLineNbr != null)
{
POLine poLine = PXSelect<POLine, Where<POLine.orderType, Equal<Required<POLine.orderType>>,
And<POLine.orderNbr, Equal<Required<POLine.orderNbr>>,
And<POLine.lineNbr, Equal<Required<POLine.lineNbr>>>>>>.Select(sender.Graph, row.POType, row.PONbr, row.POLineNbr);
if (poLine != null && poLine.TaskID != null)
{
INLocation selectedLocation = PXSelect<INLocation, Where<INLocation.siteID, Equal<Required<INLocation.siteID>>,
And<INLocation.taskID, Equal<Required<INLocation.taskID>>>>>.Select(sender.Graph, row.SiteID, poLine.TaskID);
if (selectedLocation != null )
{
e.NewValue = selectedLocation.LocationID;
return;
}
else
{
e.NewValue = null;
return;
}
}
}
base.FieldDefaulting(sender, e);
}
}
How do I override the Field Defaulting event within my Graph Extension so that the Base Method is called to set the default location, but then I can check to see if it needs to be toggled to my "alternate default location" when my specific conditions are met?