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

Building a string within ForAll

I have an approval flow and I would like to display information within the approval. I have a sharepoint list full of data and I need to display each row of data in the approval flow. Ideally I would use Set() inside of ForAll() in order to build a string of the data I need and format it, but you cannot use Set() inside of ForAll()

 

Any ideas? Has anyone else had a similar dillema before?

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User III
Super User III

Hi @Anonymous

 

One way to work around this problem is to Collect your data into a temporary collection inside your call to the ForAll function. You can then combine the rows with the Concat function to derive your complete string.

The post that I answered here uses this exact technique. Hopefully, you'll get the gist of the formula that you would use.

https://powerusers.microsoft.com/t5/Creating-Apps/Send-email-HTML-format-problem/m-p/121482#M2649

The reason why the ForAll function doesn't support the Set function is because PowerApps can execute the iterations of a ForAll loop in parallel. There's no guarantee that PowerApps will loop over the source records in order, therefore, you might need to Collect a sort value to enable you to Concat your final string in the correct sequence.

View solution in original post

8 REPLIES 8
timl
Super User III
Super User III

Hi @Anonymous

 

One way to work around this problem is to Collect your data into a temporary collection inside your call to the ForAll function. You can then combine the rows with the Concat function to derive your complete string.

The post that I answered here uses this exact technique. Hopefully, you'll get the gist of the formula that you would use.

https://powerusers.microsoft.com/t5/Creating-Apps/Send-email-HTML-format-problem/m-p/121482#M2649

The reason why the ForAll function doesn't support the Set function is because PowerApps can execute the iterations of a ForAll loop in parallel. There's no guarantee that PowerApps will loop over the source records in order, therefore, you might need to Collect a sort value to enable you to Concat your final string in the correct sequence.

View solution in original post

Anonymous
Not applicable

Thank you @timl 

 

This solution worked very well. It would be nice to see a non concurrent ForAll implementation in the future.

I have this exact same need, but am unable to look at your solution in the other post.    Is there any way you can share it here or is there another place it can be accessed?

 

@timl



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

@JR-BejeweledOne 

Google Cache is your best friend in this situation...

https://webcache.googleusercontent.com/search?q=cache:w2q7bAhHsg4J:https://powerusers.microsoft.com/...

 

I just typed this text string into Google

 

powerusers 121482#M2649

And looked at the Cached webpage instead

I get the exact same error I get when trying to go to it from the link.  

 

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

That's a pain that my original post no longer exists 😞

To summarise the technique, suppose you have a collection that looks like this and you want to convert this to an HTML table.

image.png

 

Here's the code to generate a table of results.

Collect(outputTable,"<Table>");
ForAll(Countries,
Collect(outputTable, "<tr><td>" & name & "</td></tr>")
); Collect(outputTable,"</Table>")

The result of this looks like this:

 

image.png

 

In an HTML control, you can then combine all of these rows into a single string with this:

Concat(outputTable, Value)

Hope that helps.

 

Thank you for this.   Can you show me what the 'ForAll' line in the code would look like if I have a collection similar to below and I wanted to concat the Holiday and date together so the end result string would look like this:

  Christmas Eve   12/24/2019

  Christmas Day  12/25/2019

 

Collection.jpg



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Hi @JR-BejeweledOne 

The formula would look like this:

Collect(outputTable,"<Table>");
ForAll(YourCollectionName,
       Collect(outputTable, "<tr><td>" & Name & "</td><td>" & Text(StartDate) & "</td></tr>")
);
Collect(outputTable,"</Table>")

 

Helpful resources

Announcements
PA 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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,425)