Auto submission of workflow X++
Views (232)
Hi folks,
In this blog, I am going to explain how to submit workflow automatically for approval without user interaction in D365 FO.
Requirement:
I got a requirement where in Vendor master data workflow was required to be submitted automatically for approval because Vendors were created through integration and not manually by D365 FO users.
As part of business process, vendor workflow approval process was configured and implemented for finance key users in D365 FO.
Solution:
As soon as Vendors are created through integration, submit workflow action is triggered by applying the below logic.
class AutoWorkflowSubmit
{
public static void main(Args args)
{
//Get the VendTable RecId for the vendor to submit the workflow
RecId recId;
try
{
ttsbegin;
//Pass the recId of VendTable in Workflow class that is responsible to trigger the workflow submit action
//Activate the workflow
Workflow::activateFromWorkflowType(workFlowTypeStr(VendTableChangeProposalWorkflow), recId, "@AccountsPayable:VendChangeProposalSubmit_SubmittedMessage", NoYes::No);
//Pass the recId of VendTable in VendTable class that is responsible to update the workflow status as Submitted
VendTable::updateWorkflowState(recId,VendTableChangeProposalWorkflowState::Submitted);
ttscommit;
}
catch(exception::Error)
{
throw Error("Not submitted");
}
}
}
Comments
-
-
-
VendTableChangeProposalWorkflow is WorkflowType object. It depends on you for which WorkflowType you are applying this logic. You can find WorkflowType object in AOT.
-

Like
Report
*This post is locked for comments