cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dgpadia
Advocate I
Advocate I

For each loop on Forms answers

In my form, I want the responder to be able to add multiple urls to one answer separated by commas. In flow, I want to be able to display those links in a Teams message (which I have set up and working properly). The only way I've seen to display links from a Forms response is to wrap it in HTML:

<a href="[form response]">[form response]</a>

I want to be able to display it in the teams message as 

Links: [link1] [link2] [link3] [link4]... etc.

I'm new to flow and my Google searches... I mean Bing searches... haven't turned up what I'm looking for. Chalk it up to not knowing what things are called, most likely. I've looked through expressions pages in Microsoft docs and understand that you can run loops, but I'm not seeing how to run a loop within a message body like that, only running loops over the items that are generated via actions and triggers. 2019-01-14 12_05_44-Edit your flow _ Microsoft Flow.png

 

 

I know I can split the string by whatever delimiter I tell them to, but can I then loop through the items of the resulting array and tell it to display " <a href="[item()]">[item()]</a>" for each item? The responder will be instructed to submit links separated by commas. link1, link2, link3, etc. Above is basically my full flow (minus the response submitted trigger), so I'm happy to redo any of it to get it to work the way I want. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

Hi @dgpadia,

 

I am not sure if you want to include these four links in a Teams message, or send four messages to contain these four links. Could you provide a specific example?

I guess you don't know how to reference the separated elements of the Split() function.

The Split() function splits the specified String into an array, so you could call the element just by using "Split(‘String')[index]".

If you want to automatically display the number of links based on the number of URLs populated by the user, you could configure your Flow as follows:

1. Initialize two variables, one is String, the message is stored, and the other is Integer, which is used to store the index of the link.

17.PNG

2. Use the Split() function to split the URLs based on the comma to generate an array.

split(body('Get_response_details')?['r4edc960694854603b66f7b0a90c35571'],',')

    The first parameter in the expression needs to be populated according to the actual situation of your Forms.

18.PNG

3. Traverse the array, in the format of the hyperlink, configure the array elements in the corresponding places, each time you traverse, the index needs to add one.

    Note that Current item is the Dynamic content output by Apply_to_each_2.

    And if you want the final result to show a space between the links, you need to type the space bar in the Value of the Append to string variable.

4. Finally, configure the String variable in the Message.

19.PNG

Image reference:

20.PNG21.PNG

Please take a try.

 

Best Regards,

Barry

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

2 REPLIES 2
v-bacao-msft
Community Support
Community Support

Hi @dgpadia,

 

I am not sure if you want to include these four links in a Teams message, or send four messages to contain these four links. Could you provide a specific example?

I guess you don't know how to reference the separated elements of the Split() function.

The Split() function splits the specified String into an array, so you could call the element just by using "Split(‘String')[index]".

If you want to automatically display the number of links based on the number of URLs populated by the user, you could configure your Flow as follows:

1. Initialize two variables, one is String, the message is stored, and the other is Integer, which is used to store the index of the link.

17.PNG

2. Use the Split() function to split the URLs based on the comma to generate an array.

split(body('Get_response_details')?['r4edc960694854603b66f7b0a90c35571'],',')

    The first parameter in the expression needs to be populated according to the actual situation of your Forms.

18.PNG

3. Traverse the array, in the format of the hyperlink, configure the array elements in the corresponding places, each time you traverse, the index needs to add one.

    Note that Current item is the Dynamic content output by Apply_to_each_2.

    And if you want the final result to show a space between the links, you need to type the space bar in the Value of the Append to string variable.

4. Finally, configure the String variable in the Message.

19.PNG

Image reference:

20.PNG21.PNG

Please take a try.

 

Best Regards,

Barry

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

This was my first real project with Flow, and you have helped me to understand so much more about how to use it. I understand a lot of the basic concepts of programming (I'm in school for network admin, so we learn coding concepts in C#, but I'm not a programmer), I just didn't know how to set it up in Flow/Azure Logic Apps. Thank you!!

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (60,462)