Showing results for 
Search instead for 
Did you mean: 
Super User
Super User

Ignore - figured it out! Apply To Each, Set Variable - Only the last Set Variable persists

Please ignore - user error! I wasn't passing the variable into the replace function, I was passing the original HTML each time. Is there a way to delete posts to save my embarrassment?!?!




Scenario: I create an HTML table in Flow. I want to replace several tags (<table>, <thead>,<td>) with versions that contain style information (e.g. replace <td> with <td Style = " border: 1px solid #ddd; padding: 8px;">). 


Flow: I have made a table in Excel with a column for the Tag (Element) and one for the Replacement Tag (Replacement). I initialize a string variable (strFormattedHTML) and populate it with the HTML table. I then have an 'Apply to each' which iterates through the rows of the Excel table and performs a 'Set Variable' step where I replace Element with Replacement as follows:



On the first pass of the loop, <table> should be replaced with <table Style =.... and then stored in the variable. On the next loop, <thead> should be replaced and so on, so at the end of the loop, the variable reflects all the replacements.


Issue: Every time the Set Variable step fires, it is using the initial value of strFormattedHTML, not the value from the prior iteration of the Apply To Each loop, so only the final replacement is reflected in the value of strFormattedHTML. When I check the Run History and step through the iterations of th eloop, I can see that each iteration of the loop performed exactly as expected, but the new value of strFormattedHTML is not being persisted.


Question: How can I update a variable to a new value for each iteration of an Apply To Each loop and then use the new value in the subsequent iteration?





Helpful resources

Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

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

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Users online (29,732)