Activate the BPF. Now we have our BPF on the account.
Let’s save this account record. With each Business Process Flow applied to a record, we have its own BPF record created. In our case, we called the BPF “Account BPF”. Using Advanced Find, we can see the Account BPF record and see an instance of it for Account “Test”, which is the one I just created:
Let’s check out the OData response for our BPF entity, which is called new_accountbpfs. I’m highlighting the Id of the Account, which is the instance of this flow. The account field here is _bpf_accountid_value:
I.e. Stage 1 has a process stage id of 2ada60b3-ded2-f549-4e05-4ce11f5ca891, Stage 2 has a process stage Id of 9e1f0d59-547e-4f47-b351-cf0deebb519f, stage 3 3c54b635-63ad-4d56-a2d3-ae08f582249c.
We will use these Ids shortly. Let’s add a field, and on change we will call JS to update our stage.
On running this by tabbing off our field, we see the BPF has is now at the next stage (note you may need to refresh the page to see this, or it may take a few seconds):
I did this code and it is showing success msg but it didnt go to next stage automatically. I was waiting for a few min and also tried to refresh the page. but cannot go next stage. pls advise.
Thanks
You can try below it is working fine for me in UCI 365 9.0 onpremise.
Keep a note the below guid is using stage id1 & stage id2 & BpfInstanceId which u can get from url also like he showed in browser.I think u guyz r using wrong id that’s why it is giving error.
function moveStage(executionContext){
var formContext = executionContext.getFormContext();
var action = formContext.getAttribute(“mdc_action”).getValue();
var activeStage = formContext.data.process.getActiveStage();
var stageId = activeStage.getId();
var stageName = activeStage.getName();
var currentBPFInstanceID= formContext.data.process.getInstanceId();
if (stageName==”Business Leader”)
{
if(action == 755040000){
//var Stage1 = “2ce1b836-4be9-472c-adfa-5c79f6bb2b14”;
var Stage2 = “a05a0aec-c1a1-453a-8434-90274f13447a”;
What you said is working only for one record created that time. But how to apply the same process for every record created. plz need to know this scenario.
Hii CARL DE SOUZA
actuvally i trying this code but its showing alert msg error.could plz help me.
Thanks,
Nani.
How to do this dynamically like by not giving static ID’S.. Can you please help me with that
I did this code and it is showing success msg but it didnt go to next stage automatically. I was waiting for a few min and also tried to refresh the page. but cannot go next stage. pls advise.
Thanks
Hi Guyz,
You can try below it is working fine for me in UCI 365 9.0 onpremise.
Keep a note the below guid is using stage id1 & stage id2 & BpfInstanceId which u can get from url also like he showed in browser.I think u guyz r using wrong id that’s why it is giving error.
function moveStage(executionContext){
var formContext = executionContext.getFormContext();
var action = formContext.getAttribute(“mdc_action”).getValue();
var activeStage = formContext.data.process.getActiveStage();
var stageId = activeStage.getId();
var stageName = activeStage.getName();
var currentBPFInstanceID= formContext.data.process.getInstanceId();
if (stageName==”Business Leader”)
{
if(action == 755040000){
//var Stage1 = “2ce1b836-4be9-472c-adfa-5c79f6bb2b14”;
var Stage2 = “a05a0aec-c1a1-453a-8434-90274f13447a”;
var entity = {};
entity[“activestageid@odata.bind”] = “/processstages(” + Stage2 + “)”;
entity[“traversedpath”] = stageId + “,” + Stage2;
//var BPFId = “54664223-41d6-ea11-a823-001dd8b70014”;
var req = new XMLHttpRequest();
req.open(“PATCH”, Xrm.Page.context.getClientUrl() + “/api/data/v9.0/mdc_gegroupprocesses(“+currentBPFInstanceID+”)”, true);
req.setRequestHeader(“OData-MaxVersion”, “4.0”);
req.setRequestHeader(“OData-Version”, “4.0”);
req.setRequestHeader(“Accept”, “application/json”);
req.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
//Success – No Return Data – Do Something
alert(“Success”);
} else {
alert(“Error”);
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
}
}
}
Thanks Carl for this blog….Keep on..
Thanks,
Jharana
Hello Carl,
thank you for your great Exampel
may i ask you, how we can do the same but by Power Automate?
Hi Carl
What you said is working only for one record created that time. But how to apply the same process for every record created. plz need to know this scenario.
Thank you
regards
khadar shaik