How to avoid "for each" in Power Automate when there is only one record in Dataverse List rows

There are some situations when we retrieve only a single row. To retrieve an entity record from Dataverse we generally use "List Rows" feature and this always returns an entity collection.

Hence we always need to go in "for each" loop. As shown in the below example, I am creating an email on the creation of an account entity record in Dataverse.

I have retrieved a queue to set it in "from" activity party of the email.


I know that there is only one queue record but I am helpless if I directly select "Dynamic content", It automatically creates a "for each" loop. See in below screenshots:






If I go for expression rather than "Dynamic content" then I can avoid "for each" loop, Please refer below screenshot:


Below line, I have written in expression:

outputs('List_rows_Queue')?['body/value'][0].queueid

Here "List_rows_Queue" is the above step, [0] is the first row and "queueid" is a field that
I retrieved it in the above step.

Now, If you come into this situation and want to avoid the "for each" loop in Power Automate
then use an expression in place of "Dynamic content".

Hope this helps. 😊

Please subscribe blog for regular updates.

Cheers,
Rocker


Comments

Popular posts from this blog

Power Automate: Create and attach Dataverse note or activity with an entity record through MS flow

How to send Dataverse email through PowerAutomate

How to set privilege for Activity Attachment (activitymimeattachment) in Dynamics 365 or PowerApps