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?
Solved! Go to Solution.
Hi @pcaracc
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.
Hi @pcaracc
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.
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?
Google Cache is your best friend in this situation...
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.
Click your browser's Back button to continue.
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.
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:
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
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>")
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
204 | |
187 | |
70 | |
39 | |
34 |
User | Count |
---|---|
349 | |
269 | |
122 | |
78 | |
61 |