CRM Crate

In this course, we will learn to move the business process flow to next stage using JavaScript. Before we start, make sure to go through the below courses.

Moving the BPF to next stage

We will use the method “formContext.data.process.moveNext” client API for moving the Business Process Flow to the next stage. Consider the below Account record having business process flow called “Account BPF”.

Consider the below JavaScript code which is fired during OnSave event of the form record.

function BPFMove(executionContext) {

    //Initiated Form Context.
    var formContext = executionContext.getFormContext();

    //Getting Value From Field Account Closed.
    var AccountClosed = formContext.getAttribute("accountclosed").getValue();

    //Condition If Account Closed Is True.
    if (AccountClosed === true) {

 //Moving Chevron To Next Stage.
formContext.data.process.moveNext();
    }
}

Now, if the value of field “Account Closed” is true, then after saving the record the BPF will get automatically moved to next stage by leveraging the property “data.process.moveNext()”.

Moving the BPF to Previous stage

We will use the method “formContext.data.process.movePrevious” client API for moving the Business Process Flow to the next stage. Consider the below Account record having business process flow called “Account BPF”.

This image has an empty alt attribute; its file name is img_5e6180cf8a2b4.png

Consider the below JavaScript code which is fired during OnSave event of the form record.

function BPFMove(executionContext) {

    //Initiated Form Context.
    var formContext = executionContext.getFormContext();

    //Getting Value From Field Account Closed.
    var AccountClosed = formContext.getAttribute("accountclosed").getValue();

    //Condition If Account Closed Is False.
    if (AccountClosed === false) {

        //Moving Chevron To Previous Stage.
        formContext.data.process.movePrevious();
    }
}

Now, if the value of field “Account Closed” is false, then after saving the record the BPF will get automatically moved to previous stage by leveraging the property “data.process.movePrevious()”.

CRM Crate

All In One Platform For Learning Microsoft CRM.

Facebook
Twitter
LinkedIn
error: CRM Crate Security Engine - Disabled Right Click & Selection!

Congratulations!

Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.