Using Business Rules for Calculated Fields in CRM 2013

Business Rules are a viable alternative to JavaScript for basic field calculations, such as the below example where I want Line Total to be calculated based on Unit Amount x Qty:


To automate this simple calculation I configured 3 Business Rules.  Firstly, the rule that sets Line Total =  Unit Amount x Qty (when both those fields are populated):


And two additional Business Rules to clear the Line Total field once either of the input fields are cleared:




I describe this as a JavaScript replacement and it is.  However, that doesn’t mean either JavaScript or a Business Rule is the right solution to this automation requirement.  They both have the same weakness, they only fire when the data is changed through the CRM form.   Understanding when Business Rules fire is easy, just think of them as JavaScripts.  Behind the scenes the Business Rules you author are translated into JavaScript so there really is no difference.    Implementing a calculation via just a JavaScript or Business Rule leaves your data integrity exposed to updates via Bulk Edit, Data Import, Mobile Express, API and Workflow updates where updates to your fields won’t trigger the recalc of the calculated field.   For that reason, I would meet this requirement with a combination of a Business Rule and a Plug-in.  The Business Rule provides a real time calculation experience for the user, the Plug-in ensures the calculation happens regardless of the source of the update.    Wondering whether a simple Real Time Workflow could do the job of the Plug-in?  The answer is no, the workflow designer doesn’t provide the ability to define this type of calculation.

A few other things to know about Business Rules…

Once a field is referred to within a Business Rule that association becomes part of the field’s properties, visible from the form designer:


  • When setting a field value you can only draw from fields of a similar data type.   In the example above I was able to set a Currency field based on a  Floating Point field and another Currency field.  But if I want to set a Text field based on an Option Set or Lookup field I’m out of luck.
  • When setting a field you can’t draw on any context information such as the current user or current date time.   I tried to workaround this be setting fields based on Modified On and Modified By but those values are only as current as the last save so are do not reliably give you ‘now’.

1 thought on “Using Business Rules for Calculated Fields in CRM 2013

  1. Martin Janseus

    Great post! I guess Business Rules could be used if clients easily want to modify/view their most simple rules. In reality though, I believe you could do this calculation with a workflow. You just have to split the calculations into two calculation/update steps. So workflow logic’s would be…
    1. Check so both Unit amount and Qty contains data.
    2. Update Record: Proposal [Line Total SET to Unit Amount]
    3. Update Record: Proposal [Line Total MULTIPLY BY Unit Amount]
    I believe this would do the trick 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s