top of page
pedroairo9

CRM 2015 – New Features – Write form scripts that interact with business process flows




Some times we need to extend further the product, here is a good example for doing that, interacting with the business process flow with JavaScript. Read the text below. In this release, business process flows have been enhanced to support branches based on conditions. These conditions take advantage of the newly introduced support for If-Else structures as well as support for combining multiple conditional expressions entirely using OR or AND. With these new capabilities, developers should evaluate whether existing processes that use form scripts could instead use business process flows so that organizations can maintain the logic they need without writing code. This release also makes it easier for developers to interact with the business process flows in their scripts. Form script developers have asked for a supported way to interact with the business process form user interface (UI) in form scripts. This release provides a client-side object model developers can use to interact with business process flows in their form scripts. The Xrm.Page object model is extended to include new events, methods, and objects. With Microsoft Dynamics CRM 2015 and Microsoft Dynamics CRM Online 2015 Update there is a client-side object you can use to interact with business process flows in your scripts. The Xrm.Page.data namespace is extended to include methods under Xrm.Page.data.process. The Xrm.Page.ui namespace is extended to include methods underXrm.Page.ui.process. Structure of business process flows Business process flows consist of a series of stages, each containing a number of steps. Only one stage is the active stage. When the required steps in each stage are complete, the process can move on to the next stage and it becomes the active stage. Which stage is next can be defined based on conditions in the business process flow as shown in the following diagram.

Stages can be associated with specific related entities, so a business process flow can span multiple entities. The business process remains the same and leads the user to a desired conclusion. More information: Customization Guide topic: Business Process Flows Actions that can be automated Normally, progressing along the business process depends on user input. As a developer, you can perform the same actions programmatically in form scripts. Change the process when there are more than one process available for the entity. Use Xrm.Page.data.process.getEnabledProcesses to retrieve information about enabled processes that the user can choose for the entity. Then useXrm.Page.data.process.setActiveProcess to make one of the enabled processes the active one.

Move to the next stage when all required steps are completed to make it the current active stage. Use Xrm.Page.data.process.moveNext.

Move to the previous stage and make it the current active stage. Use Xrm.Page.data.process.movePrevious.

Select a stage to view the status of the steps in the stage. Use Xrm.Page.data.process.getActivePath to retrieve information about the stages that have been completed, the current active stage, and valid stages available from the current active stage. Examine the steps included in that stage and compare the corresponding form attribute values to determine whether they are completed.

Complete a step Steps are completed when the corresponding data in the form is entered. You can determine the attribute using the step getAttribute method. This will return the logical name of the attribute. Then use Xrm.Page.getAttribute to retrieve attribute from the Xrm.Page.data.entity.attributes collection and then use the attribute setValuemethod to set the value.

Detect whether a step is required Use the step isRequired method to determine if a step is required by the business process flow.

Expand or collapse the business process flow control Use Xrm.Page.ui.process.setDisplayState.

There are also some things you can do as a developer that a user cannot perform. Hide the process control Use Xrm.Page.ui.process.setVisible, you can control whether to display the business process flow control.

Skip to a valid completed stage. Use Xrm.Page.data.process.setActiveStage to set one of the valid completed stages for the current entity.

Query the process definition including stages not currently visible Use Xrm.Page.data.process.getActiveProcess to query the definition of the business process flow, including stages that might not be visible because of branching logic in the process.

Events for business process flows


You can interact any event provided by the form with business process flows, but two new events allow you to execute code based on events just for the business process flow control. You can execute code when the active stage of a business process flow changes (OnStageChange event) or when a stage is selected (OnStageSelected event). Neither of these new events provide a user interface to register your event handlers. You must use methods provided to add or remove handlers for these events in the formOnLoad event.. More information: Business Process Flow control events



0 views0 comments

Recent Posts

See All

Comments


bottom of page