I have noticed a few posts that try to achieve for loop functionality in data transforms using recursion or some other methods. But I wonder if Pega can port the functionality from activities to work the same in data transforms:
We recently worked in a use case to initialize days of the week, where we exactly needed to initialize the seven days of the week, doing this in an activity should be straight forward, but I wish this could also be easy to do using a data transform.
Thanks for consider this idea,
***Edited by Moderator Marissa to add the Idea tag***
@josenavas , in my initial Pega programming I desired the same thing. Today, though, I see it differently.
The Data Transform's purpose is to map data between objects. Its functionality is strictly (and appropriately) limited to do that and only that. Consequently, what should we do in situations like your example (which I've also had)?
The missing piece is data! Time is the missing data! A representation of a calendar in a database table.
Borrow a trick from the data warehouse programmers' cookbook and create a time (aka date) dimension table with daily granularity. A quick Google will give you the idea. Most programmers are used to using date functions exclusively, and databases have rich date computation functions. All the same, data warehouse and report developers find these tables indispensable.
When you represent days in DB table rows, you'll next adopt a convention that will query the days residing in your week of interest. Examples:
Week 5 of calendar year 23.
Week 10 of fiscal year 22.
The week containing the date currentDate().
The week starting with date X.
Populate a list data page with these 5 or 7 days. My apps are financially oriented, so my data page is named D_FiscalDate(s). Now you have a proper data structure to drive your data transforms iterations!