Please follow the steps below to understand the methods and how to use the same in your organization.

  • Go to Download’s section and download DXrm.BusinessProcessController.zip file.
  • Extract the zip file and you would find the DXrm.BusinessProcessController.js file
  • Upload the js file as webresource in your organization.
  • For demonstration i have selected the opportunity entity and added the DXrm.BusinessProcessController.js webresource in the form for the opportunity. You can also see that there is another webresource named opportunityload.js which will be consuming the BusinessProcessController library methods. In the screenshot you can also see that I have registered a function BusinessProcessTest.FormEvents which would be called on onload of the opportunity form.

image_thumb1

  • Now let’s explore our onload function. To consume the BusinessProcessController library, it is mandatory to call the function DXrm.BusinessProcess.loadBusinessProcess(); Once you call this function, the library does all the initial set-up required to enable you to add events and gather information related to the business process flow stages.

image_thumb3

  • Now you can go ahead and register your custom event handlers when the Next Stage and the previous stage is clicked in the business process flow. Please check the screenshot below as to how to register you own custom event handlers.  One important point here – Do not forget to pass the event argument as the first argument in your handler. The event argument is required by the system to move to the next stage and previous stage using the DXrm.BusinessProcess.movePreviousStage and DXrm.BusinessProcess.moveNextStage methods where you would be required to pass this parameters.

If you need to pass any other parameter to you custom function, you can pass your object or any variable. In the example, I have passed “command” as my custom parameter.

image_thumb19

  • The below list explains the other utility methods that you can use:
    • DXrm.BusinessProcess.BusinessProcessStages : This is a property which would return the collection of the Business Process stages from where you can deduce certain stage properties. Check the screenshot below.

       image_thumb8

  • DXrm.BusinessProcess.getCurrentStageId() : Function that returns the current stage id that the record is in. You can get the same value using the OOB Xrm.Page.getAttribute(“stageid”).getValue();

 

  • DXrm.BusinessProcess.getCurrentProcessId() : Function that returns the current process id that the record is in. You can get the same value using the OOB Xrm.Page.getAttribute(“processid”).getValue();

 

  • DXrm.BusinessProcess.getStageByName(name) : Function that returns the stage object for the specified name passed as parameter. The stage object will have the properties IsActive, IsSelected, Name & StageIndex.

 

  • DXrm.BusinessProcess.getActiveStage() : Function that returns the stage object which is currently the active stage. The stage object will have the properties IsActive, IsSelected, Name & StageIndex. Check the screenshot above.
    • DXrm.BusinessProcess.getSelectedStage() : Function that returns the stage object which is currently is in focus. The stage object will have the properties IsActive, IsSelected, Name & StageIndex.

 

    • DXrm.BusinessProcess.getStageNextToActiveStage() : Function that returns the stage object which is after the active stage. The stage object will have the properties IsActive, IsSelected, Name & StageIndex.

 

    • DXrm.BusinessProcess.getStagePreviousToActiveStage() : Function that returns the stage object which is previous to the active stage. The stage object will have the properties IsActive, IsSelected, Name & StageIndex.

 

    • DXrm.BusinessProcess.getStageByIndex(index) : Function that returns the stage object specific to the index passed as parameter. When index = 0, it would return the first stage of the business process flow and so forth. The stage object will have the properties IsActive, IsSelected, Name & StageIndex.

 

    • DXrm.BusinessProcess.addOnChangeForNextStage(function, params) : Function that registers user specified event handler for the next stage click of the business process flow. Check the documentation above as to how to use it.

 

    • DXrm.BusinessProcess.addOnChangeForPreviousStage(function, params) : Function that registers user specified event handler for the previous stage click of the business process flow. Check the documentation above as to how to use it.

 

    • DXrm.BusinessProcess.moveNextStage(e) : Function to move the business process flow to the next stage. it is necessary to pass the event parameter in the function for the function to work correctly.

        image_thumb11 

    • DXrm.BusinessProcess.movePreviousStage(e) : Function to move the business process flow to the previous stage. it is necessary to pass the event parameter in the function for the function to work correctly.

          image_thumb13

         

Hope this helps!

Last edited Nov 6, 2014 at 10:53 AM by debajdu, version 5