Merged variable in portals
I need to do a calculation on a couple of fields in each row of a portal and place the respective result on each row. I placed a Merge Variable in the edit layout of the portal. I then created a script to loop through each row of the portal, do the calculation and place the calculated result in the Merge Variable field. This worked just fine if there is only one row in the portal. But if there are multiple rows, the same answer is placed in each row. I think this is because the Merge Variable has to be global so all rows get the same answer which is the answer created for the last row. I can't find any other way to do a calulation in a layout without using this Merge Variable scheme, but surely there must be some other way. I could add calculated fields to the underlying tables but that seems to be a brute force approach.
Furthermore, I will need to add a dozen or so conditional error messages to the layout which will be based on calculations involving various fields on the layout and portals which is another reason I hope there is some way to place a calculated value on the layout without using global variables or adding calculated fields to the underlying tables.