How to Implement a For Loop with a Data Transform
On a recent project my customer required a grid to be pre-populated with a number of empty rows as specified by the user. In the past I might have written an Activity rule with a For loop to accomplish this task. However, since best practice is to avoid using Activity rules as much as possible, I found I could accomplish the same task with Data Transform rules. The trick is to use the Data Transforms recursively, with each recursive call adding a row to the page list.
In my case, I used one data transform to initialize the operation and set guard conditions. The NumberOfRows parameter is provided by user input and is passed in the first call to RecursiveAppend.
The RecursiveAppend Data Transform does the work of creating the page list and setting the row number on each page in the list.
I've posted this because I haven't seen many posts about recursion or how to avoid using Activity rules. I expect this approach can be used in many situations that would otherwise require a For loop implementation.