Skip to main content

Good afternoon!

We had a question about mass updating Purchase Order numbers for Invoices after they were created. We have this functionality due to a customization that I blogged about in 2021: https://www.acumatica.com/blog/vlog-changing-an-acumatica-po-number-with-a-smart-panel-and-custom-action/

One of our staff said “Sure, we can write an Import Scenario off of that.” 

Well, it was not as easy as we thought. The smart panel is very basic.
 


https://gist.github.com/kjrichardson/4ec5742fe1cec2e245c3d1e89957e259

The code to pop it is basic as well. A simple AskExt.

 


public PXAction<ARInvoice> ChangePONbr;
PXUIField(DisplayName = "Change PO Nbr", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
PXUIEnabled(typeof(Where<ARInvoice.status.IsNotEqual<ARDocStatus.closed>.And<ARInvoice.status.IsNotEqual<ARDocStatus.canceled>>>))]
PXButton(Category = "Corrections", CommitChanges = true)]
protected virtual IEnumerable changePONbr(PXAdapter adapter)
{
if(HWChangePONbrView.AskExt() == WebDialogResult.OK)
{
ARInvoice invoice = Base.Document.Current;
if (invoice == null)
return adapter.Get();
var Filter = HWChangePONbrView.Current;
if (Filter == null)
return adapter.Get();
invoice.InvoiceNbr = Filter.NewPONbr;
Base.Document.Update(invoice);
Base.Save.Press();
}

return adapter.Get();
}

The import scenario written was basic. Invoice #, PO # from excel. Find the invoice, click the change PO # button, change the PO, then hit Ok. He could not get it to go through. I stepped in, and had to look at the code and use some reviewing of other Community posts to come up with the answer.

Looking at this post, we figured it was something to do with the order of the answer.

 
Putting the answer before the field being updated did nothing. Putting the answer before the pushing of the button did nothing as well - as per the code, it was already answered, and updated the PO # to be nothing.

So the order we had to come up with was changing the view (that was not yet on the screen), answer OK to the answer, then push the button.
 


After that, it worked perfectly, and was able to update a ton of invoices with one import scenario!

I hope this helps!

Thank you for sharing this great info with the community @Keith Richardson!


Reply