3 Replies Latest reply on Jun 20, 2014 1:50 PM by philmodjunk

    Daily Script



      Daily Script



           I am having trouble figuring out how to set up a script that runs daily. What I want is to receive an email one month before an item's expiration date in our database. I set up a calculated field that calculates this reminder date.

           Here is my issue. How do I set a script that, once per day, checks to see if today's date matches the reminder date? Then, once a year when it does match, it'll send out an email. I know how to set up a script to send an email and have done this previously where it sends an email when one clicks on a button, but I don't know how to have it run the script once a day and send an email when the reminder date is today.

           Help is greatly appreciated. Thank you. 


        • 1. Re: Daily Script

               That will depend on how you have set up your database system.

               A file hosted by FileMaker Server can have a schedule set up to run once a day and this can send mail via an SMTP client to send out the email.

               An OS based task scheduler such as windows scheduled tasks can be set up to open a FileMaker File once a day. The OnFirstWindowOpen trigger in File Options of this file can be set up to perform a script in your current file and then close. This is often called a "robot file".

               And your main file can be set up to run a script OnFirstWindowOpen that checks dates in a field to keep from being performed more than once a day or more than once a day and only then if the file has been opened on a specific user or by a specific account.

          • 2. Re: Daily Script

                 Thank you so much. This helps me figure out one major missing piece of the puzzle. Our database is hosted and I just got off the phone with the hosting service. They do allow for scheduled scripts.

                 There is just one part of the script I'm having trouble with--in the "If" part of it I am putting the calculated date field I created and the = sign and then I want to put the current date. Is there something I'm not seeing that will compare it against today's date? Or do I need to compare it against a second field that is populated with today's date? If it is the latter, how do I create a field that always contains the current date?

                 Thanks again.


            • 3. Re: Daily Script

                   I would set up the script like this:

                   Enter Find Mode []
                   Set Field [YourTable::YourDateField ; Get ( CurrentDate ) ]
                   Set Error Capture [on]
                   Perform Find []

                   This is patterned after the scripted finds you can find here: Scripted Find Examples