Close popover
Norm Selheim (selhn)
Lead System Architect - Pega Consulting
Pegasystems Inc.
selhn Member since 2013 2 posts
Posted: October 11, 2017
Last activity: October 12, 2017

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.

Enterprise Application Development Dev/Designer Studio Data Integration Java and Activities
Moderation Team has archived post,
Close popover This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Discussion, please write a new Discussion.