In a previous post, we look at how to go to the next stage in a Business Process Flow. Let’s continue this and look at more methods in the Client API to help us achieve this, including formContext.data.process.moveNext and formContext.data.process.movePrevious, which are useful if you need the BPF UI updated in real time.
If you prefer to learn by video, check out this video on my YouTube channel:
Let’s look at the BPF we have on the Account record.
If we jump into Debugger, we see there is a useful formContext.data.process, which gives us the BPF (I’ll run it below using the old Xrm.Page.ui.process):
Let’s assign a variable to this:
var process = Xrm.Page.data.process;
We can do a lot of things with this, such as attaching to the events when a user selects and changes stages in the flow.
The BPF at this point is unsaved, and therefore we can’t move to the next stage. Save the BPF:
This enables the Next Stage functionality:
Now let’s run process.moveNext(). This will automatically move the BPF to the next stage, without having to refresh the whole UI:
Running it again will continue to move it next:
And process.movePrevious() will move it backwards:
Note if you make a change that is unsaved, it will not move. You could run a save command in the JS before moving.