• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Tachytelic.net

  • Sco Openserver
    • Sco Unix Support
    • SCO Openserver Installation ISOs
    • SCO Openserver Binaries
    • Add a Hard Drive to an Openserver 5 Virtual Machine
    • Install SCO Vision SQL-Retriever ODBC Driver on Windows 10
    • License Expired on Virtual SCO Openserver Installation
    • How to reset the root password on SCO Openserver 5
  • Scripting
    • PowerShell
      • Add leading zeros
      • Check if a File Exists
      • Grep with Powershell
      • Create Environment Variables
      • Test for open Ports
      • Append to a Text File
    • VBScript
      • Check if a File Exists
      • lpad and rpad functions
      • Windows Update E-Mail Notification
  • Office 365
    • Connect to Office 365 with PowerShell
    • Add or remove an email alias using Powershell
    • Change Primary email address of Active Directory user
    • How to hide an AD user from the Global Address List
    • How to hide mail contacts from the Global Address List
    • Change the primary email address for an account with PowerShell
    • Change Primary email address of an AD User
    • Grant a single user access to access to all calendars
    • Forward email to an external address using Powershell
    • Convert shared mailbox to user mailbox with Powershell
  • Get in Touch
  • About Me
    • Privacy Policy

Power Automate: Get a single record from CDS List Records action

January 30, 2020 by Paulie Leave a Comment

You can easily retrieve the unique identifier of a record in CDS within flow using the List Records action. But this approach will create an “Apply to each” loop, even if there is only one possible result.

Image showing unwanted "Apply to Each" loop when querying a single record from Common Data Service.

I needed to get the accountid from the Account entity to create a new record in a related table. My list records action looks like this:

Image showing "List Records" action in Microsoft Power Automate.

Note that “Top Count” is set to 1.

The next step of the flow where the new record is created. You can stop the Apply to Each loop being created by using the “first” function. Example code:

first(body('List_records')?['value'])?['accountid']
Image showing how to create a new record in Common Data Service using only a single result from a "List Records" action in Microsoft Power Automate.
Image of Microsoft Flow Expression and the use of the "First" function which can give you the first result from a record set.

Then you can continue to your next action without having to deal with a for each loop. It makes the flow neater and easier to comprehend.

Related

Filed Under: Power Platform Tagged With: CDS, Power Automate, PowerTip

Reader Interactions

Leave a Reply Cancel reply

Primary Sidebar

Power Automate Support Image
Link to my LinkedIn Profile
Go to mobile version