3 Replies Latest reply on Apr 22, 2014 7:59 PM by jprochniak

    Date Triggered Email Script

    jprochniak

      Hello all.

       

      I'm new to Filemaker and have taken the approach of teaching myself the program. To get things started I've taken one of the FM13 starter solutions and have been adapting it for our purposes. In doing so I'm trying to come up with a script trigger that will send an email notification when a field value reaches a certain point such as a date or quantity. Specifically, I'd like an email sent when an inspection date is 30 days away or when a quantity of an item reaches a certain amount. I get the basic idea of scripting but I'm just not sure how to begin with writing this one in particular.

       

      Any help you guys could provide would be greatly appreciated.

       

      Thanks in advance!

       

      John

        • 1. Re: Date Triggered Email Script
          Stephen Huston

          The trick with triggering this is to decide what FM program event should be used to trigger the test of the date.

           

          The most consistent may well be to have it fire as a subscript of the file's startup script -- a script triggered when the first program window of the file is opened.

           

          You would probably also want to test for a user group which could run this subscript, as you don't want it firing everytime anyone logs in.

           

          You also will want a field in the record to record that the email was sent, probably a timestamp field, and you will then exclude records from being emailed which have already been emailed.

           

          Another, probably cleaner, solution would be to script this process without any file trigger, and then setup a Server schedule to run this script and send email notifications at a set frequency, such as 1am each day.

          • 2. Re: Date Triggered Email Script
            ariley

            You're better off having a server script run a script that checks for the field value in the field and if it matched your criteria, send the email through SMTP. 

             

            Best regards,

             

            Agnes Riley

            ZeroBlue

            • 3. Re: Date Triggered Email Script
              jprochniak

              Thanks guys for the info! After thinking about it I think the server script would be the way to go. That way I don't have to wait for someone to open the database for notifications to be sent. Good call.