By default, the submission method that is created by the Workflow Wizard is empty, so we need to add a little bit of code to tell the system what to do when the user clicks on the Submit button to initiate the workflows.
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 Submit method for the workflow to make it start the workflows running correctly, follow these steps:
- Open up the ProductApprovalWFType project, and from the Classes group, double click on the ProductApprovalSubmitManager class.
- This will open up the method browser, and you can select the main method.
Update the main method to look like this:
void main(Args args)
recId recId = args.record().RecId;
WorkflowTypeName workflowTypeName = workFlowTypeStr(ProductApproval);
WorkflowComment note = “”;
workflowSubmitDialog = WorkflowSubmitDialog::construct(args.caller().getActiveWorkflowConfiguration());
recId = args.record().RecId;
InventTable = args.record();
note = workflowSubmitDialog.parmWorkflowComment();
workflowCorrelationId = Workflow::activateFromWorkflowType(workflowTypeName,recId,note,NoYes::No);
InventTable.ProductApprStatus = ProductApprStatus::Submitted;
info(“Submitted to workflow”);
info(“Error on workflow activation.”);
- 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.