Use Replace Field to total found set

I recently needed to total up some records in a found set in a FileMaker solution, but I wanted to keep all the revisions within the scripts so that I could easily migrate the changes from the development system to production. This solution also already had quite a few “special case” calcs and fields, and I didn’t want to add any more clutter to the schema.

As it happens, there were already some Replace Field script steps being used on the found set before my grand total was needed. I piggybacked on top of one of these with a let statement



Replace Field Contents [ CONTACT::mail_list; Replace with calculation:
   Let [
      $total_sales = $total_sales + CONTACT::sale_amount 

) ];



By using the above Let statement, we get the grand total for all records in the $total_sales variable as a pleasant side-effect.

This technique should be used judiciously, or at the least explicitly called out in comments.

Leave a Reply