Skip to main content

On SOOrderEntry.cs we have the ‘Prepare Invoice’ PXAction. I’d like to add a new PXAction that allows me to run the same functionality as the InvoiceOrder method but I want to add some additional criteria to the selection of the SOLine records so I can invoice a sub-set of the details.

I suspect that I have to PXOverride the InvoiceOrder method within my customization but, here’s the challenge, I would like to leave the regular ‘Prepare Invoice’ functionality alone.

So do I have to try to copy all of the underlying code for my button or is there a way that my PXAction can do some magic ‘temporarily replace the InvoiceOrder function with this code until I’m done and then swap back in the regular InvoiceOrder function’ coding?

@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 !


Reply