Creating Flows with Lookup Attributes in the Common Data Service (Current Environment)
3rd November 2020
Welcome to the next in our series of Microsoft Dynamics 365 technical tips. This time, our Consultant, Anita Ogutu gives some useful guidance on how to correctly use connectors when using flows. For further details, call us on 0113 415 1615 or email firstname.lastname@example.org.
Microsoft currently recommend using the Common Data Service (current environment) connector for connecting to the Microsoft Common Data Service (CDS) when creating Flows (also known as Power Automate). There are three connectors available to connect to the CDS; the CDS (current environment) connector, the CDS connector and the Dynamics 365 connector. The latter is now deprecated, however.
The CDS (current environment) connector provides access to an organisation’s database in the current environment; the connection to the current environment (database) the Flow is running on is selected by default. With the CDS connector, however, one has to select or change the database to work with after deployment to a different organisation database.
How the connectors are configured for database access is not the only difference to look out for – there are also differences in how lookup attributes are populated. I was recently creating a Flow for a customer that would send a confirmation email to a Contact and on running the Flow encountered the following error “Resource not found for the segment ‘1bd87369-4bfe-ea11-a813-000d3a288c64”.
The Flow was not able to identify the Contact ID I was trying to populate on a lookup field. My investigations found that the error is linked to using the CDS current environment connector when trying to populate a lookup field and not adding that field in a specified format. This is how to proceed to resolve the issue:
- Follow the unique steps for creating your Flow and where you need to map a lookup field (as in the “Create Order Confirmation Email” action below), follow the specified format described at point 2.
Before we go ahead with how the specified format should look like, below is how to not map the lookup attribute.
- Note the specified format for mapping the lookup attribute.
To resolve the error above, the lookup attribute needs to be entered as an OData ID in the following format – EntityNameInPlural(Record’sID/GUID).
For the Contact lookup it should be /contacts(Record’sID/GUID), where the record ID or GUID would be the dynamic field for the lookup (see step 3).
- Enter the Contact lookup as an OData ID in the format noted at step 2.
The specified format for the Contact lookup attribute, which resolved the error encountered above, should look as below. Note the difference between how the Contact has been mapped below and how it was mapped in the previous image.
- Proceed with any other unique steps for creating your Flow, save and test.
If you’d like help creating Flows with lookup attributes in the Common Data Service (Current Environment) just get in touch.