Skip to main content
Community site session details

Community site session details

Session Id : xHxr1YS8LP6PF+GLd2grPL
Power Automate - General Discussion
Answered

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

Like (0) ShareShare
ReportReport
Posted on 23 Jul 2020 21:04:15 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!

 

  • Verified answer
    CU09091757-0 Profile Picture
    299 on 24 Jul 2020 at 18:07:51
    Re: How to properly convert array data from Search for Users v2, to string so that it works on Assign to: field

    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.

     

     

     

     

  • CU09091757-0 Profile Picture
    299 on 24 Jul 2020 at 04:17:02
    Re: How to properly convert array data from Search for Users v2, to string so that it works on Assign to: field

    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!

     

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

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2

Loading complete