Loop repeats exactly once - result is 2x the expected result
This is my first Filemaker project. My script is intended to add up the values in a field on a list of records. The value is recorded in a field called PurposeAmt in a table called Purpose. Purpose is in the portal on another layout. The script runs from the main layout. Eventually, I'll add a GTRR command to return to the main layout, but I need to resolve this issue. Here is the script
Set Variable [$$TransactionTotal; Value:0]
Go to Related Record [Show only related records; From table: "Purpose"; Using layout: "Purpose" (Purpose)]
Go to Record/Request/Page [First]
Set Variable [$$TransactionTotal; $$TransactionTotal + PurposeAmt]
Show Custom Dialog ["TransactionTotal is " & $$TransactionTotal]
Go to Record/Request/Page [Next; Exit after last]
The Show Custom Dialog is just for debugging purposes.
If I have five related items in the table, I can watch the custom dialog display the first item, then the next time it displays it's the first item + second item, etc. I expect it to stopp adding when it comes to the fifth and last item. However, it then goes through the list again, adding each item up. In the end, the total value of $$TransactionTotal is 2x what it should be.
How do I make it do this only once?
Thanks for any help!