The Missing Link - Get data without mappings but with calculated fields
Ever wanted to get data from a related entity? Of course you have, everyone has and it’s easy isn’t it, just update the mapping between the two entities. That’s simple, I’ll just do that.
End of Blog post….Or is it?
Maybe it’s not as simple as your first thought, maybe you need to get data from a related entity where you can’t update the mapping because there is simply no option to. At this point you have a couple of options, custom plugin but maybe you are not a developer or have the know how to do this. What about a Workflow? Yes, this is a viable option and one I would usually use but workflows can be disabled, they may be delayed in firing, you could already have a lot of workflows already and this just adds to them etc.
There is an alternative, calculated fields. What are calculated fields? Well, technet describes them as:
In Microsoft Dynamics 365, calculated fields let you automate manual calculations used in your business processes. For example, a salesperson may want to know the weighted revenue for an opportunity which is based on the estimated revenue from an opportunity multiplied by the probability. Or, they want to automatically apply a discount, if an order is greater than $500. A calculated field can contain values resulting from simple math operations, or conditional operations, such as greater than or if-else, and many others. You can accomplish all this by using the Dynamics 365 user interface, no need to write code.
But that’s not exactly what I need, I don’t need to do a calculation, I just need a value from a related entity. Au contraire mon frere. You can use this field type to get a value from a related entity, here’s how.
Open your solution (yes, use a solution as you should) and add the related entity and form you want to get this data onto. In my example, I’m using getting the existing product number onto a quote product, but the same can be applied to the opportunity product or any related entity.
Create a new field, give it a name, set the data type to Single line of text and the field type to Calculated. Click edit on the field.
On the calculation page, skip over the condition and just go to the action. Set the action to be lookupfield.field name, so in the example below I put productid.productnumber. Save and close the screen.
Put the field on your form, save, publish and close the form designer
Go to you quotes, create a quote product and voila!
Ciao for now!