Posted in CRM, JavaScripts

Switching BusinessProcessFlow With Javascript

 Switching BusinessProcessFlow 

Scenario – By default for lead entity we have  lead to Opportunity salesprocess flow. At this time we created lot of records and later we came up with another Custom BusinessProcessFlow. We need to reflect this custom businessprocessflow for all ready created records and for the new records.

Following  the code for this scenario-

function ActiveProcesses()
 {
 debugger;
 //get all active processes for an entity (OnPageLoad())
 Xrm.Page.data.process.getEnabledProcesses(function (processes) {
 for (var processId in processes)
 {
 //process id
 var processId = processId;
 //process name
 var processName = processes[processId];
 //check for process and set it active
 if (processName=="Php Process Flow")
 {
 //if the entity is has multiple active processes, the user can select which process to run
 Xrm.Page.data.process.setActiveProcess(processId, function (status)
 {
 if (status == "success")
 {
 //alert("working");
 }
 });
 }
 }
 });
 }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s