web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Auto submission of workflow X++

Muhammad Uzair Shah Profile Picture Muhammad Uzair Shah 201

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

*This post is locked for comments

  • maqkhan Profile Picture maqkhan
    Posted at
    Your blog helped me achieve my task. Thanks for sharing this.
  • AXDynamics365 Profile Picture AXDynamics365 58
    Posted at
    thank you
  • Muhammad Uzair Shah Profile Picture Muhammad Uzair Shah 201
    Posted at
    VendTableChangeProposalWorkflow is WorkflowType object. It depends on you for which WorkflowType you are applying this logic. You can find WorkflowType object in AOT.
  • AXDynamics365 Profile Picture AXDynamics365 58
    Posted at
    here you used "VendTableChangeProposalWorkflow" what is that ??