3 Replies Latest reply on Sep 7, 2012 3:45 PM by philmodjunk

    Email notification for a calendar day

    MichaelSmith2916

      Title

      Email notification for a calendar day

      Your post

      Basically im having trouble figuring out how to make a certain column in one of my databases which has calendar dates, notify an email address lets say 50 days out of the date in the column. Any help with this is greatly appreciated.    

        • 1. Re: Email notification for a calendar day
          philmodjunk

          You'll need a script that runs once a day that performs a find for records where the date is Get ( CurrentDate ) + 50. Are you hosting this database from FileMaker Server. If so, do you have an SMTP mail server you can use to send out the emails. (You've asked this question in the FM Server Forum). If so, you can schedule a script to run once a day that does this.

          If you are not hosting from FM Server, there are other methods that can perform such a script on a daily basis.

          • 2. Re: Email notification for a calendar day
            MichaelSmith2916

            Yes i am in control of the fm server (12) that is hosted at my current employer. and i do  have access to an smtp mail server that can send out emails :O

            • 3. Re: Email notification for a calendar day
              philmodjunk

              Then a script like this can find all records with a date 50 days in advance of today's date:

              Go to layout [specify layout based on table with this date field]
              Enter Find mode [] //clear the pause check box
              Set Field [YourTable::YourDatefield ; Get ( CurrentDate ) + 50 ]
              Set Error Capture [on]
              Perform Find[]
              If [ Get ( FoundCount ) ]
                 ##put your send mail code here. I don't know if you will need to loop through your records to send the emails or can use the Multiple Emails/Found Set option here.
              End IF

              Then add a schedule in your Server Admin console that runs this script once a day.

              Note that this is just a bare bones example. A more sophisticated example would set a value in a field when the email is sent and then you use criteria that specifies:

              "<" & Get ( CurrentDate ) + 50

              and you also include checking the value in this additional status field as part of your search criteria.

              With that approach, your script can "catch up" if something keeps your script from being performed on schedule. (Server went down, File was closed while deploying an update or whatever.)