The Problem:
Power Automate creates a 'Apply to each' loop when selecting dynamic content from a action that Lists items, folder, or anything.
In most cases this is awesome and creates a nice smooth workflow.
However, what about when you know exactly what you want to look for and you know its only going to be 1 record, item, whatever is going to be returned. Power Automate will still make you use the 'Apply to each' loop.
This may not be a such a terrible thing, but if you need to do multiple things underneath that action, you will have to put them in the loop as well (if you need any data or reference to that action)
Why not use a get record instead:
In some cases, yes a 'Get' action will be perfect, but this is only if you know the "Key".
In my example I only know the users 'Full Name', so I cannot use the CDS 'Get record' action.
Note:
Regardless of what connector or actions you use, this method will allow you to bypass the loop.
Solution:
Okay now on to the magic..
In my example Flow:
The expression is:
body('List_records')['value'][0]['systemuserid']
and
body('List_records')['value'][0]['internalemailaddress']
Limitations:
The only thing you have to watch out for is when there is a empty record. This will cause an error if the record is empty.
This can easily be fixed using a Condition If block before the Compose to check if value is empty using the empty() expression.
Thanks.
I hope anyone finds this useful. This boosts performance greatly when you only need one record.
—Josh
If you like my post please hit the "Thumbs Up"