You have probably already used a For each…End for each loop to work with ORDA entity selections or with collections. Its use is simple and straight forward. Would like to use it as a 4D tag in your SHTML pages? Or perhaps with the PROCESS 4D TAGS command?
As of 4D v19, you can! Keep reading to learn more.
A new 4D tag is now available: the 4DEACH tag.
Its use is very similar to a For each…End for each loop.
Just a reminder
Here is a simple example to remind you how to use a For each…End for each loop on an entity selection:
var $customer : cs.CustomersEntity
For each ($customer; ds.Customers.all())
End for each
and now let’s use the new 4DEACH tag
The following is the SHTML code to display these top three customers (Session.storage.myTop3) which is an entity selection.
We can verify the 4DEACH tag allows looping through it.
<!--#4DEACH $customer in Session.storage.myTop3-->
<td ><!--#4DTEXT $customer.name--></td>
<td ><center><!--#4DTEXT String($customer.totalPurchase;"$###,##0")--></center></td>
And here is the result:
As you can see, the syntax is very similar to a For each…End for each loop.
Download the HDI above to play with this new tag and join the discussion on the 4D forum!