cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
yoshihirok
Level 10

Sample - build a string from compose output values in apply-to-each.

I want to share how to build a string from compose outsput values in apply-to-each.

 

My scenario:

 In Apply-to-each, create new value for each item,

 After Apply-to-each, build a string by collecting new values.

 Like, Get Database records, Create new digest title from each record, After send a summarize mail by collecting the new digest titles.

 

Sample:

1. Compose: "@CeateArray(1,2,3,4,5)"

2. Apply to each

  2-1. Compose2: item

3. Compose:"@join(outputs('Compose2'), ',')"

1.png

 

Regards,

Yoshihiro Kawabata

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Sample - build a string from compose output values in apply-to-each.

Hi @yoshihirok,

 

 

Thanks for the sharing!

 

Appreciated.

 

Regards,

Michael

Community Support Team _ Michael Shao
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

8 REPLIES 8
Community Support Team
Community Support Team

Re: Sample - build a string from compose output values in apply-to-each.

Hi @yoshihirok,

 

 

Thanks for the sharing!

 

Appreciated.

 

Regards,

Michael

Community Support Team _ Michael Shao
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

Anonymous
Not applicable

Re: Sample - build a string from compose output values in apply-to-each.

Hi @yoshihirok,

 

I'm trying to build the workflow with quit the same funtionality, but every time I add a new action to join the texts, the "join action" wraps with "reapet with each" and as output I receive several join's. Could you suggest how to turn off auto addition of "repeat with each"?

Sketch.png

 

Sketch2.png

 

 

 

 

Kind regards,

Mikhail

 

Anonymous
Not applicable

Re: Sample - build a string from compose output values in apply-to-each.

I've realized that Join action has some different use, so used Compose intiad and it worked.

Highlighted
yoshihirok
Level 10

Re: Sample - build a string from compose output values in apply-to-each.

Hi, @Anonymous

 

I will re-create new Flow in this Flow Build, and reply any result.

 

and I post a Idea related do it.

Append a string to string type variable
https://powerusers.microsoft.com/t5/Flow-Ideas/Append-a-string-to-string-type-variable/idi-p/46198

for more flexibility flow.

 

Regards,

Yoshihiro Kawabata

 

 

yoshihirok
Level 10

Re: Sample - build a string from compose output values in apply-to-each.

Hi @Anonymous

 

I don't understand your cause of problem,

Try Compose with Join expression instead of Data Operations - Join action.

 

Instead of any help, I post a flow on today created.

 

1.png

 

 

1. Trigger: Schedule - Recurrence

2. Action: Data Operations - Compose

  Name = Compose

  Inputs = [ CreateArray(1,2,3) ]

3. Apply to each

3-1. Action: Data Operations - Compose

  Name = Compose 2

  Inputs = [ item() ]

4. Action: Data Operations - Compose

  Name = Compose 3

  Inputs = [ Join(outputs('Compose_2'), ', ') ]

5. Action: Microsoft Teams - Post message

  Message = [ Compose 3 - Output ]

 

This flow output "1,2,3".

 

-- [ <blue> ] is Expression.

-- [ <Purple> ] is Dynamic Content.

 

Regards,

Yoshihiro Kawabata

 

 

 

yoshihirok
Level 10

Re: Sample - build a string from compose output values in apply-to-each.

Hi @Anonymous

 

I post a idea related your problem.

 

"Data Operations - Join don't need 'Apply to each' flow. "

https://powerusers.microsoft.com/t5/Flow-Ideas/Data-Operations-Join-don-t-need-Apply-to-each-flow/idi-p/533821.png

 

 

 

Yes, 'Data Operations - Join' does NOT need 'Apply to each'.

Workaround, Can you use 'Join' expression Instead 'Data Operations - Join'

 

Regards,

Yoshihiro Kawabata

Anonymous
Not applicable

Re: Sample - build a string from compose output values in apply-to-each.

Hi @yoshihirok,

 

Thank you so much. I appreciate you help.

 

Now I understand that Join action can't be used in this situation. This is nothing I can find about it in the documentation and in which cases it can be used for.

 

Kind regards,

Mikhail

ParthaT
Level: Power Up

Re: Sample - build a string from compose output values in apply-to-each.

Hi Yoshihiro

Thanks for the suggestion.

In some complex flow (with nested apply to each for example), using a compose defined inside a apply-to outside its scope is not allowed. For instance the compose 3-1 scope is only restricted 3. Using it in 4 does not work always (in my case with nested apply to each)

 

3. Apply to each

3-1. Action: Data Operations - Compose

  Name = Compose 2

  Inputs = [ item() ]

4. Action: Data Operations - Compose

  Name = Compose 3

  Inputs = [ Join(outputs('Compose_2'), ', ') ]

 

With the recent support for "Append to Array variable" action, we can perhaps replace this with a different flow

 

2. Initialize TemporaryArray - array variable

3. Apply to each

3-1 Action: Append to array variable

Name= TemporaryArray

Value= [ item() ]

4. Compose

Expression: Join(variables('TemporaryArray'),';')

5. result we need is in Output('Compose')

 

2017-12-25_1924.png

 

 

 

 

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,101)