Calculated Fields in Microsoft Dynamics CRM 2015

Ahmed Anwar, 21 September 2014

Microsoft Dynamics CRM 2015 introduced a new exciting feature that will reduce the effort on Dynamics CRM developers.

Calculated fields are not a new Data Type in Dynamics CRM 2015 but they are fields automatically calculated after Creating/Saving a record according to the logic you create.

Calculated Fields in Microsoft Dynamics CRM 2015 

To explain the new feature, let’s assume that the Accounting Division asked you to create three fields to calculate the Net Salary for each employee. The first field is the Basic Salary and it is editable, the second field is the Tax and it is also editable and the last field is the Net Salary which is not opened for editing even for System Administrators. In older versions of Dynamics CRM, a developer had to follow cumbersome steps to develop custom plugins/workflows to implement this requirement. But in Dynamics CRM 2015 it is just few clicks.

Let’s see how we can build the logic:
Create a new field for Basic Salary (of type Currency).
Create a new field for Tax (of type Whole number).
Create a new field for Net Salary (of type Currency) but in the Field Type select Calculated and Save.
Click on the Edit button.

Calculated Fields in Dynamics CRM 2015

As you can see, the opened is almost identical to Business Rules except the Else branch does not exist and there is no need to Activate the calculation to take effect. As soon as you Save or Save and Close the calculation will take effect immediately (no publish needed).

Here are some notes about Calculated fields

• Calculated fields can be calculated using other calculated fields.
• Logic is executed even the Calculated field is not placed on a form (same plugin behaviour).
• Calculated fields can be created in System entities or Custom Entities.
• Field Type value cannot be changed after field is created.
• Logic is calculated during doing Data Imports and executing Workflows.