Categories

Microsoft Power Automate: Setting Up Lookup Value Using the CDS Connector

As you may know, Common Data Service, the sophisticated and secure backbone that powers Dynamics 365 and Microsoft Power Platform, has been renamed to Microsoft Dataverse. But in the world of Power Automate, the connector is still labeled as Common Data Service, which might change soon (no surprises there)!

Setting Up the Lookup Value

The “Current Environment” version is more feature-rich than the previous CDS connector, but it does have a few idiosyncrasies to look out for. One of these is the setting and clearing of a lookup value (entity reference) on a create/update operation. In the old connector, you could just use the unique id (GUID) of the entity you wish to set, and all would work fine. However, with the latest connector, this is not the case.

When you select a Trigger or Action and search within Common Data Service, you will see two CDS connectors. For this article, we will use the new Common Data Service environment.

microsoft power automate cds

In this simple example, when a Contact is created, it will automatically create an Account for that Contact and set the Primary Contact on that Account to the newly created contact. You used to be able to select the Contact id from the Dynamic Content (from the Create trigger) and drop it into the Primary Contact lookup field on the creation of the account, as shown below, and it would all work within the old connector.

microsoft power automate contacts

However, if you do this in the “Current Environment” connector you get a “Resource Not Found for Segment” error when the Flow is executed.

The way to resolve this is by formatting it as you would if you were setting the single-valued navigation property using the @odata.bind annotation (see Associate entity records on create as an example).

The format is a “/” followed by the entity’s plural name, followed by the unique ID wrapped in parentheses. For example, /contacts(00000000-0000-0000-0000-000000000001).

Here is what the updated flow should look like:

microsoft power automate create account

Test Flow using data from a previous run

microsoft power automate test flowAs you can see, the flow will now run successfully.

 

power automate flow testing

Let us look at the Account record to confirm.

power automate account records

Clearing the Lookup Value

In the new CDS connector, you need to use the new “Dissociate entities” action to clear or remove lookup values.

Note: This has recently been renamed so it may now appear as “Unrelate records” but it is the same action under the hood.

microsoft power automate common data service

This might seem slightly counter-intuitive, but the Entity Name should be the name of the entity reference you are trying to clear. The Item ID should match the associated Item ID.

You then choose the applicable entity relationship to disassociate, in this case, account_primary_contact. Finally, specify the Disassociated Item full URL identifier as shown below.

power automate disassociate entities

The newly renamed version look like this:

microsoft power automate unrelate records

Now, when I create the Contact, the Account will originally get created with the Primary Contact as the created contact — subsequently, this will be cleared by the “disassociate/unrelate” action.

Contact “John Halsey” has been created.

microsoft power automate search results

The account created with the Primary Contact that is then cleared.

power automate account contact

If you have questions about Power Automate or optimizing your workflows, contact our experts today!


Leave a Reply

Your email address will not be published.

X