We’ve used the Acumatica REST API previously to create an invoice in one step (a PUT) and then releasing it directly after that (a POST). – so essentially a two-step process.
We have a client that is wondering if it is possible to do this all in one call to increase the efficiency of the process.
Is this possible?
Thanks…
Here is a potential solution, though I haven’t tried it:
Let’s say you have a field that indicates if the Invoice was created through the API. You can check this flag in the Persist override, and than release your invoice after calling the base method.
Don’t forget to clear your flag before calling Release.
[PXOverride]
public virtual void Persist(Action baseMethod)
{
baseMethod?.Invoke();
if ("APIInvoice" == true)
{
"clear flag";
Base.release.Press();
}
}
You can’t insert a record (create invoice) and call an action (release invoice) in a single API call.
That said you can create and call a custom action. This action can create and release invoice in a single call. The action can take custom parameters. Use those parameters to pass invoice values.
Reference for calling custom action with REST API:
https://help.acumatica.com/Help?ScreenId=ShowWiki&pageid=f01f3b8b-56c4-48ab-a043-dcbb10e3bfb3
You could use the in-product Business Events and Action Executions features to automate the Release of Invoices meeting certain conditions, in your case, Invoices that were Created By the relevant api user, and any other conditions to ensure only the Invoices you want to be auto-released are included.