6 Replies Latest reply on Jul 29, 2010 11:26 AM by AAgraphics

    Install OnTimer Script Question, maybe there is a different solution.

    AAgraphics

      Title

      Install OnTimer Script Question, maybe there is a different solution.

      Post

      FWP 10 - on Mac and PCs

       

      I have a table that contains information on products that we are developing.  I was wondering if the "Install OnTimer Script" could be used for something that we need.

       

      We have products that are supposed to ship from factories on a certain day.  We enter the ship date into FileMaker.  Can we then have a timed event where an email is automatically sent to the vendor two days after the ship date?  Can this be done in FileMaker using the Install OnTimer Script?  Or is there a different way to do this?  Thanks!

        • 1. Re: Install OnTimer Script Question, maybe there is a different solution.
          philmodjunk

          Only if you keep a client copy of filemaker up and running continueously or structure your script to recalculate and restart the the timer events each time you open filemaker on a specific machine or with a specific window.

           

          It might be easier to set up a script that uses the current date to search this table for all records where such a reminder email is "due" and then sends the emails.  You can set this script to run automatically the first time you open the file on a client machine or possibly as a server scheduled script (IF you get SMTP configured the correct way on your server so filemaker server can send emails.).

          • 2. Re: Install OnTimer Script Question, maybe there is a different solution.
            AAgraphics

            Your second option sounds fantastic!  How would you write the script to search the table against the current date and then send an email two days have passed?  And how would you write it so it does not send an email out when three or more days have passed?

             

            - Better yet, if it could send one email and then the script will not send another email if one has already been sent.

            • 3. Re: Install OnTimer Script Question, maybe there is a different solution.
              philmodjunk

              You add at least add two fields to your table: cDate Due and Emailed.

              Define cDate Due as a calculation field that returns a date: Ship Date + 2

              Define Emailed as a date field. It'll record the date an email was sent.

               

              Your script works something like this:

               

              Enter Find Mode[]

              Set Field [Table::cDate Due ; "< " & Get ( CurrentDate ) ] //inequality operator handles cases where file wasn't opened every day

              Set Field [Table::Emailed ; "="] //specifies Emailed field must be empty

              Set Error Capture [on]

              Perform FInd []

              If [ Get ( FoundCount ) > 0 ]

                 Loop

                     Send Mail[.....

                      Set FIeld [Emailed ; Get ( CurrentDate ) ]

                     Go To Next Record [Next; Exit after last]

                 End Loop

              End If

               

              Since your script finds date due records only if the Emailed field is blank, the emails are sent out only once.

              • 4. Re: Install OnTimer Script Question, maybe there is a different solution.
                AAgraphics

                Phil,

                I was finally able to build the script, with some modifications.  See the image below:

                Script

                We have a database of projects.  We send each project out for quoting to a maximum of six different places.  Some projects are sent only to two places for quoting, others three, etc.  So each project has a max of 6 RFQs.

                Each RFQ has five dates:

                Date of 1st RFQ ( Quote11RFQSent )

                Date of 1st RFQ plus 5 days ( Quote1RFQplus5 )

                Date of 1st RFQ plus 8 days (Quote1RFQplus8 )

                Date of 2nd RFQ ( Quote21RFQSent )

                Date of 3rd RFQ ( Quote31RFQSent )

                We want the above script to automatically check the RFQs and send a second RFQ after five days have passed from the 1st RFQ.  We also want the above script to automatically check the RFQs and send a third RFQ after eight days have passed from the 1st RFQ.  Project Managers can manually send second and third RFQs and if this happens, the dates are automatically entered and the script above should not send second and third RFQs for those projects.

                Here are a couple of errors that happened:

                1. The script sent second and third RFQs for two projects where there was no date in the 1st RFQ ( Quote11RFQSent ).  The field was blank and I thought I have set where the script is searching for a date that is greater than 07/28/2010.
                2. If the script sends an email it should enter in the date in certain fields and it did not enter the dates.

                Any ideas?  Does this make sense?  Also, when the script is performing its searches, how can I get the script to ignore records with certain fields that are blank?  If the following field is blank, these records should not be included in the search results: Quote11RFQSent

                If you have any questions, please let me know.  Thank you and I hope this was not too confusing.

                • 5. Re: Install OnTimer Script Question, maybe there is a different solution.
                  philmodjunk

                  I don't see any obvious errors in the script.

                  Each of these fields should be either date fields or calculation fields set to return a date type and your "date sent" fields cannot be calculations fields.

                  Those are the only possibilities I can think of that would explain this.

                  If you have filemaker advanced, you might use the debugger to step through the script and see what the values are in the fields at each point where this goes wrong.

                  • 6. Re: Install OnTimer Script Question, maybe there is a different solution.
                    AAgraphics

                    I found out what was causing the problem!  I was missing an important step in the script "Perform Find"!  I placed it after every "Set Error Capture" and now the script appears to be working fine.  Thank you!!!