Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Changing BPF through javascript

Posted on by 55

Hi 

i found below code on MSDN, please help how to use this. or very helpful if i get any other alternate.. thanks

//A namespace defined for SDK sample code
//You should define a unique namespace for your libraries
var Sdk = window.Sdk || { __namespace: true };
(function () {
 //A global variable to store information about enabled business processes after they are retrieved asynchronously
 this.enabledProcesses = [];

 // A function to log messages while debugging only
 this.writeToConsole = function (message) {
  if (typeof console != 'undefined')
  { console.log(message); }
 };

 //Code to run in the OnLoad event 
 this.formOnLoad = function () {
  //Retrieve Enabled processes
  Xrm.Page.data.process.getEnabledProcesses(function (processes) {
   //Move processes to the global Sdk.enabledProcesses array;
   for (var processId in processes) {
    Sdk.enabledProcesses.push({ id: processId, name: processes[processId] })
   }
   Sdk.writeToConsole("Enabled business processes flows retrieved and added to Sdk.enabledProcesses array.");

   //Write the values of the Sdk.enabledProcesses array to the console
   if (Sdk.enabledProcesses.length < 0) {
    Sdk.writeToConsole("There are no enabled business process flows for this entity.");
   }
   else {
    Sdk.writeToConsole("These are the enabled business process flows for this entity:");
    for (var i = 0; i < Sdk.enabledProcesses.length; i++) {
     var enabledProcess = Sdk.enabledProcesses[i];
     Sdk.writeToConsole("id: " + enabledProcess.id + " name: " + enabledProcess.name)
    }
   }

   //Any code that depends on the Sdk.enabledProcesses array needs to be initiated here

  });
 };

}).call(Sdk);

*This post is locked for comments

  • RE: Changing BPF through javascript

    i want to change the process dynamically through javascript based on some field change

  • Verified answer
    ARIFNIIT Profile Picture
    ARIFNIIT 1,391 on at
    RE: Changing BPF through javascript

    What is your requirement? Are you trying to activate business process? refer this article

    https://www.powerobjects.com/2015/10/13/business-process-flows-and-javascript/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans