Business Rules With Actions Lock, Unlock And Show Error Message

Introduction

In Dynamics 365 CRM or Power Platform, business rules provide a quick way of applying business conditions every business rule starts with a condition. In this article, we are going to see about 2 Actions Lock/Unlock and Show Error Message with a business scenario on contact entity if Vaccination is done, then lock discount field and if Vaccination is not done and when a user tries to enter discount more than 50% then an error message will be shown to the user that maximum discount cannot exceed 20% else any discount.

Step 1

Login to the required Dynamics CRM/ Power Apps environment using URL make.powerapps.com by providing user name and password and go to solutions as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 2

After step 1, select the custom solution here. Then select ContactCustomizations custom solution as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 3

After step 2, in the ContactCustomizations custom solution open Contact Entity and then click on the Business Rules tab, and then click on Add business rule as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 4

After step 3, a new Business rule window gets opened provide Business Rule name and meaningful description and provide condition if Vaccination field have yes as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 5

After step 4, select Lock/Unlock Action and drag it to the right side/ true part of the Condition Verify Vaccination Field as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 6

After step 5, click on Lock/Unlock Action from the designer and provide Display Name as Lock Discount and Entity as Contact, and under the Lock/Unlock section select field Discount and Status as Lock and click on Apply Button as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 7

After step 6, in the else part of Verify Vaccination Field and another condition block and name it If Discount >20% and in the rule section select Discount field and check operator Is greater than and Value as 20 and click on Apply as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 8

After step 7, in the true part of Discount > 20 %, then place Action Lock/Unlock and keep Discount field as unlock and place Show Error MessageAction and Keep Display Name as Discount Alert and Entity as Contact under Error Message Section. Select Field as Discount and provide Message as Discount Cannot be greater than 20 %. 

Click on Apply as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 9

After step 8, under the false part of Condition if Discount >20 %, keep an action for Lock/Unlock Discount and make Discount field status as Unlock and click on Apply. Click on Save and Activate Business rule as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 10

After step 9, now navigate to contact entity and open any record, and select Vaccination field as yes. We can observe Discount Field as a locked field as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Step 11

After step 10, now navigate to contact entity and open any record and select Vaccination field as none / No. We can observe in Discount Field if Value is entered more than 20%, then an error message will be as shown in the below figure.

Business Rules with Actions Lock,Unlock and Show Error Message

Note

  1. Please make sure you keep the required fields on Contact Form.
  2. Select fields for Actions as well as for Conditions without fail.
  3. Make sure to Activate Business Rule after save.
  4. Publish all changes without fail.
  5. Give the name of conditions and Actions names in a meaningful way.

Conclusion

In this way one can easily perform Business validations with Lock and UnLock and Show Error Message Actions in few minutes can be built.