cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ADMCharles
Level: Powered On

Splitting string and performing action for each?

I found a question from almost a year ago about splitting a string into and array of substrings.

 

This was suggested as the solution by yoshihirok and v-micsh-msft:

 

1.PNG

 

I have since attempted to set up a flow with identical parameters and it fails, it appears to not be actually splitting the string but

passing the whole input in the compose action. Here's a shot of the error I get.

 

Capture.PNG

 

Is there some sort of formatting error with my JSON? When I set it up to just blast me an email with the output it sends me "@split('Hello #a1',' ')"

2 ACCEPTED SOLUTIONS

Accepted Solutions
ADMCharles
Level: Powered On

Re: Splitting string and performing action for each?

Found the problem, JSON has to be encapsulated in " " (double quotations) to actually execute or else it'll be sent as a string.

View solution in original post

Highlighted
ADMCharles
Level: Powered On

Re: Splitting string and performing action for each?

What worked for me, and be prepared for it to change because flows seems to be changing regularly, is wrap the entire JSON command in quotes. I suspect this is because it is a Key:Value pair to be sent in a REST request to flows backend in Azure.

 

E.g. (Compose)

"@split('This-String-Will-Split','-')"

 

 

and (Compose 2 in applyforeach)

 

"@item"

 

 

But when the flow is saved and run it appears in the edit view as this (Take note that the second output is from the @item output not the first compose.):

 

Capture

 

So in my case, I was working on enabling notifications to groups in flows rather than just each user. I created a workflow in SP that uses an admin account to check against group members in a given group selected by the user creating a notification. The admin account then adds a temporary entry for each user in the group split by a comma. This is where I use the for each you see. The section in the first compose "triggerBody()?['Group_x003a_Members']?['Value']" gets the linked list I'm using and gets the 'Group_x003a_Members' field containing the list of items to split. I then send a message to each of them and voila! We now have a notification center backend to send reminders to departments and groups.

 

Hope this helps a little with your endeavours once you see "@split(a,b)" and "@item()" used in a real example. Flows is not quite there yet for most production systems but get your learning in now so you can be ahead of the curve. Feel free to ask me any questions, I don't know much but I'll tell you what I can.

 

Kind Regard,

ADMCharles.

 

 

View solution in original post

4 REPLIES 4
ADMCharles
Level: Powered On

Re: Splitting string and performing action for each?

Found the problem, JSON has to be encapsulated in " " (double quotations) to actually execute or else it'll be sent as a string.

View solution in original post

Anonymous
Not applicable

Re: Splitting string and performing action for each?

having the same problem - where do the double quotes go?

Highlighted
ADMCharles
Level: Powered On

Re: Splitting string and performing action for each?

What worked for me, and be prepared for it to change because flows seems to be changing regularly, is wrap the entire JSON command in quotes. I suspect this is because it is a Key:Value pair to be sent in a REST request to flows backend in Azure.

 

E.g. (Compose)

"@split('This-String-Will-Split','-')"

 

 

and (Compose 2 in applyforeach)

 

"@item"

 

 

But when the flow is saved and run it appears in the edit view as this (Take note that the second output is from the @item output not the first compose.):

 

Capture

 

So in my case, I was working on enabling notifications to groups in flows rather than just each user. I created a workflow in SP that uses an admin account to check against group members in a given group selected by the user creating a notification. The admin account then adds a temporary entry for each user in the group split by a comma. This is where I use the for each you see. The section in the first compose "triggerBody()?['Group_x003a_Members']?['Value']" gets the linked list I'm using and gets the 'Group_x003a_Members' field containing the list of items to split. I then send a message to each of them and voila! We now have a notification center backend to send reminders to departments and groups.

 

Hope this helps a little with your endeavours once you see "@split(a,b)" and "@item()" used in a real example. Flows is not quite there yet for most production systems but get your learning in now so you can be ahead of the curve. Feel free to ask me any questions, I don't know much but I'll tell you what I can.

 

Kind Regard,

ADMCharles.

 

 

View solution in original post

Userofoffice365
Level: Powered On

Re: Splitting string and performing action for each?

Hi,thanks, but what if we want to make a different action for each item ?

 

For example I would like to copy each item in their own excel columns.

 

thanks !

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (6,878)