Calculation Using Business Rules in Microsoft Dynamics CRM

Hi Guys,

We all love business rules & i am a big fan of them since they save alot of your time developing javascript for small actions that you need perform for e.g from making a field mandatory to setting fields value or showing error message.

Well , fortunately business rules can help if you need to perform some simple calculation on a form based on field values too. Lets get into action.

I have thought of a silly scenario where if i have estimated closed date on opportunity – i would like to set a date of 10 days before the estimated closed on a custom date field that i have created. Based on that i can then perform some other action using this new value either with JavaScript or business itself. This is dynamics crm 365 trial that i am using but its pretty much similar in 2016 or 2015.

So lets create a business role.

  1. Add a new condition to check if Est. Closed date contains data AND the new field(date difference) doesn’t not contains data.
    please note that if we don’t check the second condition the business rule will run every time and set the value to date difference on every on load even if date difference has been set last time :1
  2. Now once we are done with condition , lets add the action to it “set field value”. and from right side select the field = “date difference” , Type = “Formula”, other field = “Est Closed Date” , Operator = “-“, Type = “Value” , Days = “10”. Take a look at reference below:
    2
    3
  3.  now lets apply , save , Activate the business rule.
  4. Lets open a record a with estimated closed date and see it in action 🙂
    4
  5. the date difference field has been set to 10 days before the est close date which is 24-02-2017.
    5.PNG

There you go , it was simple example but i am sure you can perform some more complex calculation and not on just date fields but on currency and other fields.

Hope this helps!

Cheers!

Advertisement