{Scripting titbits} Coming in Dynamics CRM 2015: Business Process Flows{Part 1}

I was going through documentation on new scripting tit-bits coming in Dynamics CRM 2015 in scripting. Basically there is a new section in namespace coming up for Business Processes: 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 under Xrm.Page.ui.process.

In CRM 2015, Business Process flows can have a structure like the one below:

clip_image001

This and other scripting changes included solves lots of workaround and unsupported scripting which needed to be done till Dynamics CRM 2013 to meet customer requirements. Methods and usage are mentioned below (Reference 2015 Developer Preview SDK):

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 use Xrm.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 setValue method 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.

Things only developer can 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 stage without progressing through each one.

Use Xrm.Page.data.process.setActiveStage to set one of the valid stages returned using Xrm.Page.data.process.getActivePath as long as the stage is defined 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.

Get Active Process:

var activeProcess = Xrm.Page.data.process.getActiveProcess();

Set Active Process:

Xrm.Page.data.process.setActiveProcess(processId, callbackFunction);

Get Active Stage:

var activeStage = Xrm.Page.data.process.getActiveStage();

Hope it helps!

Advertisements

2 thoughts on “{Scripting titbits} Coming in Dynamics CRM 2015: Business Process Flows{Part 1}

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