cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Convert array to string

 I have an array of items that I need to convert into a string. I need the text to go into a plain text email form which is submitted into our ticketing system.

 

I've tried various `join` and `concat` options but can't get the result I expect. The data comes from a multiple entries group/person field from SharePoint via a PowerApps form. I have transformed the data to an array, but this is where I am stuck.

 

I want to go from this:

 

 

[
  {
    "DisplayName": "Bob Jones",
    "Email": "bob.jones@example.com",
    "JobTitle": "Singer"
  },
  {
    "DisplayName": "Jane Doe",
    "Email": "jane.doe@example.com",
    "JobTitle": "Lighthouse Painter"
  }
]

 

 

 

 

To this:

 

 

Bob Jones - bob.jones@example.com - Singer
Jane Doe - jane.doe@example.com - Lighthouse Painter

 

 

Any help appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @IntrepidExploer,

 

I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a Variables-> “Initialize variable” action, Name set to OriginalArray, Type set to Array and Value set to the array that you provided.
  • Add a Variables-> “Initialize variable 2” action, Name set to FinalString, Type set to String and Value set to empty.
  • Add a “Apply to each”, “Select an output from previous steps” field set to variable OriginalArray.
  • Within “Apply to each”, add a “Compose” action, Inputs set to following formula:
concat(item()?['DisplayName'],' - ',item()?['Email'],' - ',item()?['JobTitle'])

 

Add a “Compose 2” action, Inputs field set to following formula:5.JPG

Note: Within Inputs field, type Output dynamic content of “Compose” action in first line, then type variable FinalString in second line (type “Enter” key in your keyboard).

 

Add a “Set variable” action, Name choose FinalString and Value set to output of “Compose 2” action.

 

  • Under “Apply to each”, add a “Compose 3” action, Inputs set to variable FinalString.

Image reference:6.JPG

 

7.JPG

The flow works successfully as below:8.JPG

 

9.JPG

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
v-xida-msft
Community Support
Community Support

Hi @IntrepidExploer,

 

I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add a Variables-> “Initialize variable” action, Name set to OriginalArray, Type set to Array and Value set to the array that you provided.
  • Add a Variables-> “Initialize variable 2” action, Name set to FinalString, Type set to String and Value set to empty.
  • Add a “Apply to each”, “Select an output from previous steps” field set to variable OriginalArray.
  • Within “Apply to each”, add a “Compose” action, Inputs set to following formula:
concat(item()?['DisplayName'],' - ',item()?['Email'],' - ',item()?['JobTitle'])

 

Add a “Compose 2” action, Inputs field set to following formula:5.JPG

Note: Within Inputs field, type Output dynamic content of “Compose” action in first line, then type variable FinalString in second line (type “Enter” key in your keyboard).

 

Add a “Set variable” action, Name choose FinalString and Value set to output of “Compose 2” action.

 

  • Under “Apply to each”, add a “Compose 3” action, Inputs set to variable FinalString.

Image reference:6.JPG

 

7.JPG

The flow works successfully as below:8.JPG

 

9.JPG

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-xida-msft,

 

Thanks for your help. That's an excellent solution. I really appreciate the time you put into producing that example.

 

Cheers.

Anonymous
Not applicable

Just what I needed. Awesome solution. Thanks a lot.. 

Anonymous
Not applicable

Can this work for a Sharepoint List?

 

for example I have two emails seperated in items in a List. I want to join (Concat) the emails together to send a approval to multiple people base of the Sharepoint list. Im trying with Get Items but i don't seem to get it. Im new with Microsoft Flow

 

Thanks

@v-xida-msft 

Thank you very much for the solution. It really helped.

hi @v-xida-msft 

 

I have somewhat similar requirement but cannot go through it with your current solution.

 

I have this as my original array:

[
  {
    "Field 1": "Value 1.1",
    "Field 2": "Value 1.2",
    "Field 3": "Value 1.3",
    "Field 4": "Value 1.4"
  },
  {
    "Field 1": "Value 2.1",
    "Field 2": "Value 2.2",
    "Field 3": "Value 2.3",
    "Field 4": "Value 2.4"
  }
]

 

Initially, I want to send an email containing the array which I have transformed to HTML Table like this:

Field 1Field 2Field 3Field 4
Value 1.1Value 1.2Value 1.3Value 1.4
Value 2.1Value 2.2Value 2.3Value 2.4

 

But as it turned out, the table layout is to tight because my table has too many columns to fit in a HTML view. So I decided to transform the layout into something like this:

Field 1: Value 1.1
Field 2: Value 1.2
Field 3: Value 1.3
Field 4: Value 1.4

Field 1: Value 2.1
Field 2: Value 2.2
Field 3: Value 2.3
Field 4: Value 2.4

but I cannot figure out how to transform the original array.

 

Appreciate if you can look into it and help. Many thanks.

DanielS19
Frequent Visitor

Is it possible to skip lines for each string?

Is it possible to skip lines for each string ?

Thank you so much for posting this; it worked perfectly!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (2,239)