| Anas Arshad

Automatically update the BPF Stage by JS

Sometimes you need to work with BPF stages and automatically navigate through the stages based on your business needs. For quick testing, you can use the D365 client API to navigate using the predefined moveNext and movePrevious methods in the browser console window before writing any JavaScript code. 

You can use the moveNext method to navigate to the next stage in the business process. As shown below;

var activeProcess = Xrm.Page.data.process.getActiveProcess;

if (activeProcess != null) {

Xrm.Page.data.process.moveNext(function (result) {

if (result == "success") {

// ** Code for success goes here

alert("Success");

} else {

// ** Code for failure goes here

alert("Failure");

};

});

};

You can use the movePrevious method to navigate to the next stage in the business process. As shown below.

var activeProcess = Xrm.Page.data.process.getActiveProcess;

if (activeProcess != null) {

Xrm.Page.data.process.movePrevious(function (result) {

if (result == "success") {

// ** Code for success goes here

alert("Worked");

} else {

// ** Code for failure goes here

alert("failure");

};

});

};

You can set the active stage, by using the ID of the stage.

var GUID = "15322A8F-67B8-47FB-8763-13A28686C29D";

Xrm.Page.data.process.setActiveStage(GUID, function(result) {

if(result == "success") {

    alert("Success");

} else {

    alert("Invalid");

}

});

Note: In variable GUID, Pass the id for the stage that you want active.

Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.



About The Blog

Stay updated with what is happening in the Microsoft Business Applications world and initiatives Imperium is taking to ease digital transformation for customers.


More About Us

We provide guidance and strategic oversight to C-Suite and IT Directors for on-going implementations. Feel free to give us a call.

1 331 250 27 17
Send A Message

Ready to Start?

Get a personalized consultation for your project.

Book a Meeting