In This Article

    Share

    Calculated Fields and Parent Entities in Dynamics 365 for Customer Engagement

    Calculated fields made a big splash when they were first introduced back in Dynamics CRM 2015.  For the first time, system customizers had a tool to perform calculations in the system without having to resort to JavaScript or a plugin.

    Today, in Dynamics 365 for Customer Engagement, calculated fields continue to be a reliable tool in the system customizer’s arsenal.  However, one often overlooked feature of calculated fields is that they are not limited to the data on a single record, and can actually leverage data on parent records too.  To do so, find the parent entity lookup schema name in the rule action field followed by a period (.).  The list of available fields will change to those of the parent entity.

    How to Use Calculated Fields

    Here is an example of how this can be used.  Consider the scenario where an insurance company wants a way for sales people to use opportunities to track their sales and calculate commissions.  Multiple sales people can work on the same opportunity, and the commissions would be divided between them based on a defined percentage.  To meet this requirement, we will create a custom entity “Commissions” that will calculate the commissions for each salesperson based on the commission rate and agreed upon split.

    1. On the Opportunity entity, create a field “Commission Rate”.
    2. Create a custom entity, “Commission.”
    3. In the “Commission” entity, create the following fields:
      1. Opportunity (Lookup to Opportunity entity)
      2. Sales Person (Lookup to User entity)
      3. Split (Decimal)
    4. Save and Publish all customizations. If you do not Save and Publish, sometimes some of your fields will not appear in the calculated field rules.
    5. In the “Commission” entity, create the “Commission” calculated field (Currency) with the following rules:
      1. (Optional) Set the Conditions:
      2. It’s generally a good idea to add conditions such as these so that you can prevent “Null” values when certain values are blank.  Alternatively, you can also make those values required fields, or you can set default values or use business rules to populate them.
      3. Set the actions. Notice what happens when we type the name of the lookup “mu_opportunity” into the field.  The filtered results show only the lookup field on the Commission entity:
      4. However, when we add the period (.), the filtered list changes and we’re able to see all of the opportunity fields.
      5. Finish building the rest of the rule as follows:
      6. Build a view for your “Commission” entity and place it as a subgrid on your opportunity form.
      7. Save and Publish all customizations.

    And our end result:

    As you can see, using a calculated field we are able to create a function that involves data from two different entities to create a simple commissions function without requiring any JavaScript or plugin work, or even out of box workflows.  Calculated fields offer a quick and easy solutions to a lot of business process automation needs, and being able to reach into other entities makes them even more effective.

    For additional questions on Dynamics 365 for Customer Engagement, contact Hitachi Solutions today.