@ddunn Try using a flag to condition the execution of the additional logic you would like to add when overriding the InvoiceOrder method as follows:
public class yourExtension : PXCacheExtension<SOOrderEntry>{
public bool runCustomCode = false;
public void delegate InvoiceOrderDelegate(Dictionary<string, object> parameters, IEnumerable<SOOrder> list, InvoiceList created, bool isMassProcess, PXQuickProcess.ActionFlow quickProcessFlow);
/PXOverride]
public void InvoiceOrder(Dictionary<string, object> parameters, IEnumerable<SOOrder> list, InvoiceList created, bool isMassProcess, PXQuickProcess.ActionFlow quickProcessFlow, InvoiceOrderDelegate baseMethod){
baseMethod(parameters, list, crated, isMassProcess, quickProcessFlow);
if(runCustomCode){
//yor code
}
}
/PXButton]
public void YourButton(){
try{
runCustomCode = true;
Base.InvoiceOrder(...);
}
finally{
runCustomCode = false;
}
}
I’ve tried that but the value of runCustomCode seems to be false. I think that’s because the code within PrepareInvoice (which calls InvoiceOrders which calls InvoiceOrder) creates a new graph of SOOrderEntry and that doesn’t have the variable that I need - the graph extension does. I might not have investigated enough but decided to head in a different direction.
What I ended up doing, because there isn’t much code, was to create my own PXAction and then copy the code for PrepareInvoice, InvoiceOrders, and InvoiceOrder and then added my own logic within the InvoiceOrder code. It won’t be hard to upgrade as I haven’t done much so I’m not too worried.
I would like the code used to select the detail lines to be turned into a method so that it can be overridden all by itself if any of the Acumatica developers have some extra time. ;)
Thank you for sharing your solution with the community @ddunn !