To prepare data in a similar manner, one can utilize the Moqui API within an #assign directive in an FTL file. However, it is generally recommended to handle this within the screen.actions element of the corresponding screen rather than directly in the FTL file.
For examples on using the Moqui API through an ec.entity.find() call in an FTL snippet, refer to the SimpleScreensSetupData.xml file located in the moqui/SimpleScreens repository. This file contains data that populates the database to incorporate a header navbar item with a concise FTL template displaying relevant messages and events.
An excerpt from the file exemplifies this:
<#assign taskCount = ec.entity.find("mantle.work.effort.WorkEffortAndParty").condition("partyId", ec.user.userAccount.partyId!).condition("statusId", "not-in", "WeClosed,WeCancelled").condition("workEffortTypeEnumId", "WetTask").disableAuthz().count()>
To successfully utilize this data for iteration, you will require a modified version of this code snippet that retrieves a list for iteration using the FTL #list directive.