HOW TO CHANGE BUSINESS PROCESS FLOW (BPF) STAGE IN JAVASCRIPT

In this previous post, we saw how to register and call event handlers related to the BPF.

In this post, we will see how to change the Business Process Flow (BPF) stage in JavaScript that will be directly reflected in the UI.

In order to achieve this, you have to use the functions formContext.data.process.moveNext() and formContext.data.process.movePrevious() so you can move the stage back and forth in the active BPF of the form.
  1. Go to the entity form and open the form or field properties where you want to call the JavaScript function
  2. Under the Events tab, add the appropriate event handler and call the function that will change the BPF stage
  3. Save and Publish the form
  4. As outlined in the below JavaScript function, use the moveNext or movePrevious functions to change the BPF stage.

    function moveBPFToNextStage(context) {
    var formContext = context.getFormContext();
    formContext.data.process.moveNext();
    }

    function moveBPFToPreviousStage(context) {
    var formContext = context.getFormContext();
    formContext.data.process.movePrevious();
    }
  5. At the end, and based on your action, the end result would be as follow
    Change BPF Stage in Javascript

Bonus Tip:
If you make a change that is not saved yet, the BPF stage will not be changed. Therefore, call the save method in the JavaScript and then move the stage.


Hope This Helps!

Comments

Popular posts from this blog

DYNAMICS 365 HOW TO HIDE RECENT RECORDS FOR LOOKUP FIELD IN UCI

SEARCH BY GUID IN DYNAMICS 365

SAVE FORM IN DYNAMICS 365 JAVASCRIPT