Back to Basics # 17: Business Rules with Scope Entity and Server-Side Execution

Introduction:

In Dynamics 365 CRM or Power Platform, updates in entity data by using service call /SDK which do changes in server side, then server-side business rules will fire i.e., business rules with scope Entity will fire. As a business scenario we are going to see updates in contact entity by invoking service call  through Post Man Tool which invokes business rule with Entity Scope.  

Step 1:

Login to the required Dynamics CRM/ Power Apps environment using URL make.powerapps.com by providing username 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, Create a business rule with scope as Entity and name business rule with Show Business Required Fields in Contact And Set Visibility. Logic here is if the field Birthday have value, then field Vaccination becomes mandatory and Discount field will be shown save business rule and activate and then publish the solution as shown in the below figure.

Step 5:

After Step 4, create a record in contact entity in selected Dynamics CRM Environment with a service call using Post Man tool and prepare request json as per the below format

{

    “firstname”: “James”,

    “lastname”: “M”

}

And once json is prepared, in Post Man tool open a new request tab and provide required authentication related to CRM Environment paste above json in request body with the selection of raw and format as JSON as shown in the below figure

Step 6:

After Step 5, before creation of record, open respective CRM Environment and verify the contact is not present in the list of contacts as shown in the below figure

Step 7:

After Step 6, go to step 5 and click on Send Button and once you receive response then a record gets created in the crm Environment as shown in the below figure

Step 8:

After Step 7, go to crm environment and select contact entity and see the results you should see newly created record with name James M as shown in the below figure

Step 9:

After Step 8, open newly created James M record and see Discount field not populated and Vaccination field is not business required as shown in the below figure

Step 10:

After Step 9, copy record id of James M contact record so that we can update this record using Post Man tool by providing Birthdate as shown in the below figure

Step 11:

After Step 10, open Post Man tool and prepare a new request to update contact record with a field using Patch Verb and prepare a request with respective json body for Birthday field using the below json

{

    “birthdate”: “2000-07-01”

}

 and click on Send button if everything works fine then record gets updated as shown in the below figure

Step 12:

After Step 11, navigate back to crm environment and open/ refresh James M record and see birthdate got populated and the respective business rule which was created in Step 4 fires and makes fields Vaccination as Business Required and Discount Field shows up in the form as shown in the below figure

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 and give scope as.
  4. Publish all changes without fail. Entity
  5. Give name of conditions and Actions names in a meaningful way.
  6. Make sure to configure CRM Environment in Post Man tool to use for Create and Update operations.
  7. Take proper care to see json was well formed or not.

Conclusion:  In this way any server-side operations happen in CRM, respective business rules with scope Entity gets fired.


Discover more from Common Man Tips for Power Platform, Dynamics CRM,Azure

Subscribe to get the latest posts to your email.

4 thoughts on “Back to Basics # 17: Business Rules with Scope Entity and Server-Side Execution

  1. Pingback: Rewind August 2021 – Common Man Tips for Power Platform, Dynamics CRM,Azure

  2. Pingback: Rewind August 2021 - Microsoft Dynamics CRM Community

  3. Pingback: Back To Basics # : Curated List of Articles in a Single Page – Common Man Tips for Power Platform, Dynamics CRM,Azure

  4. Pingback: Back To Basics :Curated List of Articles in a Single Page - Microsoft Dynamics CRM Community

Leave a comment