The final update that we need to do on our workflow type is to add some code top the Approval Handler to tell the workflow what to do when the workflow completes.
NOTE: This is part of the Developing a Product Approval Workflow in Dynamics AX 2012 blog series where we show how to develop a completely new workflow to manage the new product approval process. If you want to see all of the other posts in this series, click here.
How to do it…
To update the Approval Event Handler, follow these steps:
- Open up the ProductApprovalWFType project and open the Classes group select the ProductApprovalEventHandler class.
- This will open up the method browser, and you can select the completed method.
Update the completed method to look like this:
void completed(WorkflowEventArgs _workflowEventArgs)
forupdate InventTable where InventTable.RecId == _workflowEventArgs.parmWorkflowContext().parmRecId();
InventTable.ProductApprStatus = ProductApprStatus::Approved;
- After you have updated the method, save it, and if there are any syntax errors, then you will be able to correct them here in the editor. When everything is fine, you can code out of the method editor.
- Just to be sure, save your project to make sure that there aren’t any other grammatical errors in the code.