4
votes

I am using Dynamics 365 online instance to integrate sales process. I have one condition where I need to change the Probability field value to 100 when user clicks on Finish button in Close Process Stage.

enter image description here

I have done some research and found that (OnProcessStatusChange event) can help to get business process flow status change (statuses: Active, Finished, or Aborted)

Ref Link: OnProcessStatusChangeEvent

I have checked this by adding this to form OnLoad event like below, but nothing happens.

Xrm.Page.data.process.addOnProcessStatusChange(setProbablityOnFinish);

Is there any other solution?

1
Does the eventhandler ‘setProbablityOnFinish’ exist?Arun Vinoth
Yes ‘setProbablityOnFinish’ is already there which i haven't mentioned in my post.Cyber
any error on browser console? Debug result?Arun Vinoth

1 Answers

5
votes

Make sure you implement the eventhandler like this, it will work.

function OnLoad() {
   Xrm.Page.data.process.addOnProcessStatusChange(statusOnChange);
}

function statusOnChange() {
   status = Xrm.Page.data.process.getStatus();
   if (status == "finished") {
       //Write your logic here//
   }
}