web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / D365 Life without Code / Business Rules, Calculated ...

Business Rules, Calculated Fields and Workflows – What one should I choose?

Pitipe Profile Picture Pitipe 686

Lets look at the scenario where we have the ‘forecast’ field on the opportunity which is ‘calculated’ with the formula (Est. Revenue * Probability) /100

  1. When you create the field – Forecast you create it as a calculated cell and put the formula in the action
  2. You create forecast as a standard field and then you create a workflow to create the calculation
  3. You create forecast as a standard field and then you apply a business rule to create the calculation
  4. You could use code

All 3 methods will work and for an experienced person would take similar amounts of time to create. In case this is new let’s quickly go through each of the non code methods.


So we can compare ‘side by side’ I will create 3 new fields and put them on the form – I have created them all as currency fields

I am also going to make both the Est. Revenue and the Probability mandatory fields, there is no point having rules and calculations in place if people don’t populate with data.

Calculated Fields

 I will create a field called forecast calculate with the data type currency fields and the field type calculated

Workflow

I will create a field called forecast workflow to use for this method with the data type currency fields and the field type simple

I am creating the workflow to run on creation or if either probability or Est. Revenue changes and to run real time

The workflow will be in 3 steps.

  • Populate forecast with the value from Est. revenue
  • Multiply by the Probability
  • Divide by 100 – although as there isn’t a division as an operator multiplying by 0.01 will have the same effect (note: if you have the field as whole number this will not work)
  • Save and activate the workflow

Business Rule

I will create a field called forecast br to use for this method with the data type currency fields and the field type simple

Create the business rule and set the scope to run on all forms

Create the condition to check if the Est. Revenue field contains data

If it does create the action to preform the calculation

You then need a second action to divide by 100

I have also put in an action to set the value to zero if there is nothing in the est revenue

Your rule is now complete – save and activate the rule

Let’s test

After you have published all your changes open an opportunity and check to see if the different methods all work

As soon as you click on save everything should update

For the formula we had in this scenario I personally would favour the calculated cell as I think it is neater as we had the 3rd step to divide by 100 but all work so it is personal choice.  There are a lot of thing you can do with both calculated cells and business rules which you may previously have done via workflows and code in the past. Next time you need a calculation have a think about the effort and maintenance in each of the methods and see which suits that situation best.


This was originally posted here.

Comments

*This post is locked for comments