问题
I have to override function to create drop ship PO and update custom field in PO Table based on sales price margin goes below certain percentage. I have gone through the source code for POCreate. The PO is created through static function
public static PXRedirectRequiredException CreatePOOrders(List<POFixedDemand> list, DateTime? PurchDate, bool extSort)
How to override and add my logic to creating drop-ship PO?
回答1:
The best way would be to attach event handlers on what you need. This is not a simple case but here's an example I wrote a couple months ago. This code is changing the POLine description to add "Test" at the end. You could use it populate your custom fields too.
public class POCreateExt : PXGraphExtension<POCreate>
{
public override void Initialize()
{
PXGraph.InstanceCreated.AddHandler<POOrderEntry>((graph) =>
{
graph.RowUpdating.AddHandler<POLine>((sender, e) =>
{
POLine line = e.NewRow as POLine;
POOrderEntry.SOLineSplit3 soLine = PXResult<POOrderEntry.SOLineSplit3>.Current;
line.TranDesc = soLine.TranDesc + " TEST ";
});
});
}
}
来源:https://stackoverflow.com/questions/37249625/updating-user-defined-field-in-poorder-while-creating-drop-ship-po