Introduction:
In Dynamics 365 CRM or Power Platform, Business rules provide a quick way of applying business conditions and 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 user tries to enter discount more than 50% then a error message will be shown to the user that maximum discount cannot exceed 20 % .
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.
Step 2:
After Step 1, select custom solution here select ContactCustomizations custom solution as shown in the below figure.
Step 3:
After Step 2, in ContactCustomizations custom solution open Contact Entity and then click on Business Rules tab and then Click on Add business rule as shown in the below figure.
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.
Step 5:
After Step 4, select Lock/Unlock Action and drag it to right side/ true part of Condition Verify Vaccination Field as shown in the below figure.
Step 6:
After Step 5, Click on Lock/Unlock Action from designer and provide Display Name as Lock Discount and Entity as Contact and under Lock/Unlock section select field Discount and Status as Lock and click on Apply Button as shown in the below figure.
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.
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 Message Action 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 % and Click on Apply as shown in the below figure.
Step 9:
After Step 8, under 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 and Click on Save and Activate Business rule as shown in the below figure.

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

Step 11:
After Step 10, now navigate to contact entity and open any record and select Vaccination field as none / No and 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.

Note:
- Please make sure you keep the required fields on Contact Form.
- Select fields for Actions as well as for Conditions without fail.
- Make sure to Activate Business Rule after save.
- Publish all changes without fail.
- Give 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.
Pingback: Rewind August 2021 – Common Man Tips for Power Platform, Dynamics CRM,Azure
Pingback: Back To Basics # : Curated List of Articles in a Single Page – Common Man Tips for Power Platform, Dynamics CRM,Azure
Pingback: Back To Basics :Curated List of Articles in a Single Page - Microsoft Dynamics CRM Community