Purpose:
In this post we’re going to learn how can we submit a pending vendor invoice to approval workflow in X++.
Application:
Dynamics 365 for Finance and Operations
Business requirement:
Submit a pending vendor invoice to approval workflow in X++.
Solution:
We can use the code below to submit a pending vendor invoice to approval workflow.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /// <summary>/// Submits vendor invoice to workflow./// </summary>public static void main(Args _args){ WorkflowComment workflowComment; TradeLineRefId headerReference; VendInvoiceInfoTable vendInvoiceInfoTable; headerReference = "COMP-011202"; workflowComment = "Auto submission to workflow."; vendInvoiceInfoTable = VendInvoiceInfoTable::findTableRefId(headerReference); if (vendInvoiceInfoTable) { try { VendInvoiceHeaderWorkflow::submitToWorkflow(vendInvoiceInfoTable, workflowComment); } catch (Exception::CLRError) { System.Exception interopException = CLRInterop::getLastException(); error(strFmt("%1", interopException)); } catch (Exception::Error) { error(strFmt("An error occured during the update.")); } }} |
Comments
Post a Comment