Home > CRM > Power Automate | Dataverse | Create row by setting lookup column with ‘Key’

Power Automate | Dataverse | Create row by setting lookup column with ‘Key’

Imagine you’re in the midst of creating a Contact record in Cloud Flow using Dataverse > Add a new row action. You can easily set the ‘Company Name’ field, which is a lookup, with the syntax: accounts({account_guid}), as shown below.

Did you know that instead of parent record’s GUID, you can also use the Alternate Key to set the look up column?. In this article, let’s learn how to set the lookup column using Alternate Key.

What is an Alternate Key:

  •  With alternate keys you can now define a column in a Dataverse table to correspond to a unique identifier (or unique combination of columns) used by the external data store.
  • This alternate key can be used to uniquely identify a row in Dataverse in place of the primary ke (i.e., GUID).

Steps to Create a Key:

To create an alternate key in Account table,

  • Navigate to Account > Keys
  • Click on New Key and choose column as shown below. I’ve chosen Account Number column.
  • Click on Save

  • Wait for some time until the status changes to Active.
  • Now, go ahead and create a new Account record with ‘Account Number’. Copy the value of the ‘Account Number’ (i.e., 989898) which we will be using in the flow.

Now that we have created an alternate key in the Accounts table and added a new Account record, let’s proceed with creating a flow to generate a Contact record using the account’s alternate key.

Create a flow:

  • Create an Instant Flow.
  • Add Dataverse > Add a new row action.
  • Set the ‘Company Name’ lookup column to accounts(accountnumber=’989898‘). Here is an explanation of the syntax.
    • accounts : Schema name of ‘Account’ table.
    • accountnumber : The logical name of the column configured in Keys.
      • Since we configured the ‘Account Number’ column in ‘Keys’, use ‘accountnumber’, which is the logical name of the ‘Account Number’ column.
    • 989898 : Account Number value of the Account record.
  • Save and Test the flow. You will notice that the Add a new row action succeeds.
  • Open the Contact record in Dataverse, and you will notice the Account Name look up is set with the ‘Contoso Ltd’ Account.

Hope you learned about using alternate keys while setting up lookup columns in flows.

🙂

Categories: CRM Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment