AnsweredAssumed Answered

How do I write a script to find the largest value in any table?

Question asked by DonColacino on Aug 15, 2016
Latest reply on Aug 21, 2016 by DonColacino

I have a routine to sync two filemaker pro 14 databases with multiple tables. I want to set a global field in the receiving database to show the most recent record modification date.  Every table has a field named "ModDate."  In my script, I import a file containing a set of records.  The part I'm having trouble with is finding the most recent "ModDate" value from the records just imported.  My assumption is that all the records in the table I've just imported to would be my "found set," and that I could then use the "sort records" command make the record with the most recent "ModDate" record 1. Something like this:

      Go to Layout ["My sort layout"]

   Show All Records

   Sort Records [Restore; No dialog]


The sort records script step seems to require an explicit table name to be specified and doesn't seem to allow it to be specified by a calculation.  However my script will be run on all tables, and I specify the table with a variable called $TableName.  Is there a way to find the largest "ModDate" in any table I happen to be operating on without having to write a separate set of script steps for each table?


Thanks in advance for your insight.