DESCRIPTION
The Option-Set (Choice) and Lookup fields in Microsoft Dynamics CRM are special. The Option-Sets are essentially a combination of Integer Values and Labels, whereas the lookups are GUIDs plus the name of the parent record. In this blog, we will learn how we can fetch option-set labels and lookup names with simple OData expressions in MS Power-Automates (Cloud Flows).
For instance – A D365 CE case record as a field called Origin, which is an Option-Set. The Customer field is a lookup to account or contact entity.
In this blog, we aim to build a Cloud Flow to retrieve Case Origin labels & Customer names using OData expressions and store them in variables.
STEPS
- We open our D365 CE Solution and create a new Cloud Flow titled “Case – Get Origin and Customer”.
- The trigger for this flow would be to create a new Case.
3. We add the next action Get a row by ID to fetch all the properties of the newly created case.
4. We then create a new string variable CaseOrigin which is supposed to hold the label for the Case Origin Option Set.
We initialize its value with [OData format] –
@{outputs('Get_a_row_by_ID')?['body/caseorigincode@OData.Community.Display.V1.FormattedValue']}
5. We create one more string variable called CaseCustomer which will hold the customer’s (account/contact) name.
We initialize its value with [OData format] –
@{outputs('Get_a_row_by_ID')?['body/_customerid_value@OData.Community.Display.V1.FormattedValue']}
6. Finally, we save these changes in the Flow.
UNIT-TESTING
I. We create a new Case in D365 CE to trigger the Power-Automate.
ii. We confirm that the Power-Automate has triggered, the Case Origin label and Customer name are correctly saved the variables.
Case Origin Label
Customer Name
CONCLUSION
Hence, we learned how we can make use of OData expression to fetch an Option-Set label and a lookup name in a Power-Automate (Flow). This saves us a great deal of time and effort.
That’s it from Aegis in this blog, see you in our next blog