3 Replies Latest reply on May 22, 2012 4:02 PM by philmodjunk

    Script Issue



      Script Issue


      I have a table with the below fields and data


      Month     -       Year        -  Month/Year      -       Submitted     -   DueDate

      Jan                 2012        Jan/2012                    1              25/01/2012

      Feb                 2012        Feb/2012                   1              25/02/2012

      March              2012        March/2012                1              25/03/2012

      April                2012        April/2012                  1              25/04/2012

      May                2012         May/2012                  0              25/05/2012

      June               2012        June/2012                  0              25/06/2012


      Now I want to know how to write an automatic script which will run on 20th to 25th of every month and should send a email to xyz@gmail.com of the current month if the value in the status field is 0, otherwise if the value is 1 it should not send the email.


      e.g the current month is MAY 2012 and the value of Submitted is 0, so an email should be sent out to xyz@gmail.com. Please note that the script sould only send an email of the current month and the records are pre entered into the table of the complete year from Jan to Dec.

        • 1. Re: Script Issue

          The Script is the easy part:

          Go to Layout[Email Log]
          Show All Records
          Go to Record/Request/Page [Last]
          If [ ( EmailLog::DateSent + 5 )< Get ( currentDate ) ]
            Enter FInd Mode []
            Set field [YourTable::Duedate ; Month ( get ( CurrentDate ) ) & "/" & year ( Get ( Currentdate ) ) ]
            Set Field [YourTable::Submitted ; 0 ]
            Set Error capture [on]
            Perform Find[]
            IF  [ get ( FoundCount ) // at least one record found ]
               Send Mail
               Go to Layout [Email Log]
               New Record/Request
               Set Field [Email Log::DateSent ; Get ( CurrentDate ) ]
            End If
          End If

          But scheduling the script to run on a specific day of the month is the real challenge here.

          You could set this script to run every time the file opens if you open the file nearly every day.

          A system scheduler can be set to open a robot file to connect to your database and run this script every day or every month.

          If the file is hosted with Filemaker Server, a server schedule could be set to run this script once a day. (You'd need to use SMTP to send out the email.)

          • 2. Re: Script Issue

            Thanks alot Phil, but the Submitted field value 0 or 1  is set by another script. I only want this script to send an email if the Submit field value is 0.

            • 3. Re: Script Issue

              And that's why there's this step in the script:

              Set Field [YourTable::Submitted ; 0 ]

              It specifies 0 as the find criteria in this field for the scripts find. It does not modify data in any actual records because the database is in Find MOde at this point.