web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to properly conver...
Power Automate
Unanswered

How to properly convert array data from Search for Users v2, to string so that it works on Assign to: field

(0) ShareShare
ReportReport
Posted on by 299

Within my flow, I'm just about done but I am running into an issue.

I am using the Search for Users v2 to get an email address of a staff member in my organization.  If I try to reference that email address into my To: field, within my Start and Wait for Approval connector, it automatically wraps that section with another Apply to Each 2.  Further more, the Assign to: field only takes strings.  

To avoid this automatically wrapping, and producing an error, I took the following steps....

I initialized my variable at top level:

kensley_0-1595537641420.png

 

Then within my original "Apply to each" wrapper, I set my outputs from previous steps:

 

kensley_1-1595537716614.png

 

Further inside my "Apply to each" wrapper, I append to string variable:

 

kensley_2-1595537793721.png

 

Finally, within my Start and wait for an approval connector, I am assigning the approvers email variable to the Assign to: field.

 

Everything saves perfectly, but when I run my flow, it errors out halfway stating the following:

 

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@{triggerOutputs()?['body/value']}@{variables('approvers email')}' is of type 'String'. The result must be a valid array.

 

If I am overcomplicating things, I apologize.  I simply want the array value of the email address stored in Search for Users V2, to be converted to a string, so that it will work within my Assign To field. 

Thanks for any suggestions!

 

Categories:
I have the same question (0)
  • CU09091757-0 Profile Picture
    299 on at

    I spent some time trying to re-construct my process to make it less complex.  Now within my workflow area this is what I have....

    * The Search for Users V2 connector

    * Below that, a Composer (Data Operation) connector so that I can start playing with arrays of data

    * Within my expression field for that connector, I made it this far - string(outputs('Search_for_users_(V2)')?['body'])

    Now, when I run my flow and see my results, that displays the full array....

     

    [{
    "Id":"...",
    "AccountEnabled":...,
    "BusinessPhones":["..."],
    "City":"...",
    "Mail":"..."
    }] 

     

     

    How can I improve my string expression further to simply get the "Mail" property?

     

    Many thanks!

     

  • Verified answer
    CU09091757-0 Profile Picture
    299 on at

    I eventually was able to to get a string conversion from my JSON object relating to the Search for Users v2 connector, by

    * Adding my trigger.

    * adding a "Apply to Each" action.

    * Within here, adding all my base connectors, including the Search for Users v2 connector.

    * Adding a Compose connector, to capture the object into an array form.

    * Under that, adding a Apply to Each action to then Compose, and convert one of my previous array data values into a string.

     

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard