How to Create Business Rules in Dynamics 365


In Microsoft Dynamics 365 the creation process when creating a business rule is significantly different, in a good way! The business rules still use programming logic in a more visual and simplistic manner. Business rules are more than just business logic, they are extremely useful, and can be used to lock fields, hide fields and display errors on fields. I will walk through how to create a business rule to ensure that the end date for an event is after the start date, and to display an error message next to the field if it is not.

Creating the business rule

  1. Open a solution containing your entity, or customize the default solution.
  2. Navigate to the entity that the business rule will be placed on.
  3. Then find ‘Business Rules’ beneath the entity.
  4. Click new.

Initially there’ll be a condition with no rules applied to it. I then created two rules to be used with an ‘and’ conjunction (Rule Logic) which means they both must be true for an action to occur.

image thumb How to Create Business Rules in Dynamics 365
 
Above you can see that the finish date must be less than (before) the start date and that the finish date must contain data. The finish date must contain data so that the error isn’t displayed when no data has been entered in the field. In the red box, there’s a nice view which displays the logic once it has been implemented.
 
Next, there’s an action that occurs when both conditions have been satisfied. In this case an error message is displayed that is shown in the below image. An action can be added to a condition by dragging the action from components to the right of the condition. Adding an action below the condition makes the action an ‘else’ action.

image thumb 1 How to Create Business Rules in Dynamics 365

This shows the simplicity when creating business rules in Dynamics 365, it is easy to pick up, edit and implement.

Highlighting over the red X shows the error message.
  image thumb 2 How to Create Business Rules in Dynamics 365

Let’s block ads! (Why?)

Magnetism Solutions Dynamics CRM Blog