There are times when you need to display data from a related entity on a form without the overhead of replicating the information across entities. Quick View forms are a good way to do this if you are pulling multiple fields from the entity and displaying them in one column. To learn more on Quick View Forms, check out our previous post: Exploring the Quick View Forms in CRM 2013. If you need the flexibility to show fields in multiple columns or if you only need one field, calculated fields may be the way to go.
In this blog, we will show you how to use calculated fields to display discrete data from a related entity. To do this we will use the following scenario. Let’s say I need to display a Company’s Credit Limit on an Opportunity record. We can do this by adding a calculated field to the Opportunity Entity and then adding that to the Opportunity form. Let’s see it in action.
Step 1 – Create the Calculated field
1. Navigate to Settings > Customizations > Customize the System.
2. Expand the Opportunity entity and select Fields.
4. Add a Display Name and Description for the new field.
5. Select Calculated as the Field Type.
Note: We are using the Currency Data Type for this field to ensure that the value is formatted correctly when we add it to the form.
6. Select the Edit button to open the Field Definition Editor.
7. Next, we will want to add an Action by clicking the Add Action button.
8. Click into the edit control and select parentaccountid from the list.
9. Type a “.” after parentaccountid and select Credit Limit from the dropdown list.
Note: Adding the “.” after any lookup field will allow you to use related entity fields in your action step.
10. Select the Check button to save your action.
11. Click the Save a Close button on the Field Definition Editor to commit your changes
12. Select Save and Close on the New Field from to update the system Schema
Step 2 – Add the Calculated field to the Opportunity Form
1. Open the Opportunity Form where you would like to display Credit Limit and navigate to the appropriate section.
2. Select the Credit Limit field from the Field Explorer and add it to the form.
3. Save and Publish your customizations.
4. Once you refresh your browser you will see the Credit Limit displayed on your Opportunity form.
For more info and additional uses of calculated fields, visit the Calculated Fields section of The CRM Book!
Happy Dynamics 365’ing!