Trigger Business Rules on change of Stages of Business Process Flow

By | April 18, 2016

Introduction:

Among many advanced features introduced in Microsoft Dynamics CRM 2016, one would be business rules getting invoked by a business process flow. Earlier with MSCRM 2013, business rules were introduced to provide custom business logic and eliminate the need of writing scripts around this logic. But now with Dynamics CRM 2016, some of the UI based logic whose behaviour depends on Business Process Flow and its stages can be handled easily.

In this blog we will take a look at how the business rules get invoked.

Example:

Consider a scenario, where the management at a health care unit uses CRM to provide medical services to patients. As per the policy, 50% discount is given to the patients whose age is either equal to or greater than 60 years after they have received treatment. In order to keep a track of their patients, the management at the health care unit adhere to a business process flow. Depending on the age of the patient, the stages of the Business Process Flow can be changed. Now, based on the various stages, if we want to show / hide the discount field, which is by default disabled (hidden) on the Patient form then follow the business process flow as shown in the screenshots below.

Trigger Business Rules

Now we will use this Business Process Flow and its stage as a condition set in Business Rules. When the stage ‘Is A Senior Citizen’ is selected or active the hidden field i.e. ‘Senior Citizen Discount %’ field can be displayed using Business Rules as follows.

Trigger Business Rules in crm

As you can see we have selected Business Process in the ‘Field’ section of the Condition, and have selected the second option i.e. ‘Value With Stage’ among the two options provided in the ‘Type’ field. Once ‘Value With Stage’ is selected another line is added to filter out our condition depending on the Stage of the Business Process Flow. So, we get the values as shown in the screenshot below.

Trigger Business Rules in Dynamics CRM

The CRM provides you with two options ‘Active Stage’ and ‘Selected Stage’ with which we can define whether we want actions to be performed when the stage is either selected or when the stage is active.

Note: - If a Business Process Flow isn’t present regarding an entity then, while creating a Business Rule you would

Find the Value field to be locked because you won’t have any process to access, as shown below

Trigger Business Rules

image

As per our Business Rule shown above, the field ‘Senior Citizen Discount %’ is made visible on the ‘Patient’ form which is by default hidden, when we select the stage ‘Is A Senior Citizen’.

Note: - There is major difference between ‘Selected Stage’ and ‘Active Stage’ that one needs to understand.

- ‘Selected Stage is when you select any stage of the Business Process Flow manually irrespective of it being active or inactive.

Selected Stage

‘Active Stage’ is when the process is currently residing in a particular stage as per its flow that has been pre-defined or preset.

Active Stage

Our ‘Business Rule’ will work in the following manner, as shown in the image below.

Business Rule

As you can see in the above image ‘Senior Citizen Discount %’ field is not visible. But as soon as we select the ‘Is A Senior Citizen’ stage of the Business Process Flow the ‘Senior Citizen Discount %’ field becomes visible, as shown in the image below with red boxes.

Business Rule

Then we can enter some information to the field, as shown below

Business Rule in CRM

Conclusion:

It is therefore evident from the screenshots as above that scripts need not be written for performing UI based actions on the form in Dynamics CRM 2016. Instead, rules can be used for the business process flows to streamline the experience and lead the user towards the desired outcome.

You may like to revisit our last quarter most popular Blogs about Dynamics CRM.

Leave a Reply