1 Reply Latest reply on Mar 29, 2010 10:32 AM by TSGal

    Server Script Using Two Files



      Server Script Using Two Files

      Your post

      I am trying to run an automated server script that spans across two files.  Here is the setup:


      In File1 there is a Staff table that lists all demographic information for employees.  In File2 there is a table for time sheets.  The two tables/files are linked by staff_id.  I want to run a script that automatically emails staff who have overdue time sheets.  This works when the email address is stored in the time sheet table, but the real location is in the staff table in File1.


      Doing some Googling I have seen that when a server runs a script it cannot go between files even though there are relationships between the two.  Is there a way to directly reference a related field so that the server can grab data from another file?

        • 1. Re: Server Script Using Two Files



          Thank you for your post.


          Assuming you have a relationship into your second file, use the Sum() function in a calculation to total the records in the second file.  This total will then appear in the first file, and that information can be evaluated and used in a script.  For example, your script may look like:


          Go to Record/Request/Page [ First ]


             If [  Value > 1000 ]

                Send Mail [ SMTP Server ; No dialog ; ......   ]

             End If

             Go to Record/Request/Page [ Next ; Exit after last ]

          End Loop




          That is, we go to the first record and enter a loop.  We evaluate to see if the Value (Calculation) is greater than 1000.  If so, then we send an email.  Regardless, we skip to the next record and exit the loop after finished.


          If you need clarification, please let me know.



          FileMaker, Inc.