13 Replies Latest reply on Jul 6, 2015 10:17 PM by philmodjunk

    How to set up script



      How to set up script


      I have in each record a number field thats calculating time down to 0. Then I need a script to send out an email when a particular record reaches 0 in that field. (basically a timer counting down)  I tried an install timer script that runs every 5 seconds, to check with a loop thru records script. That works in itself but then other tasks are not working or canceled when the script is called. Im sure theres a better approach.  thanks for your help.

        • 1. Re: How to set up script

          It would help if you would be more precise about what it is you're trying to achieve.

          I understand the part about the timer counting down and sending an e-mail but it's difficult for me to understand the context of such a function and why you would need to send these e-mails with such precise timing.

          • 2. Re: How to set up script

            Ok sure. The database is tracking irrigation wells. When a well is started I set timer say at 15 hrs. and one of the functions of the database is to remind me when a well needs to be turned off. Using an email to text me that reminder is what i'd like. A good example is 15 wells running with maybe 3 times a day getting a text to turn one off. Now the precision i'm guessing your referring to is running the install timer script every 5 seconds and yes that is more than I need. Was just using that to experiment. In the end i'd probably be interested in say every 5 min. But if the user is trying to edit a field, or a popup is engaged then  it cancels that out when the script runs.  Chances of this happening get less the greater the interval and at some point I could live with that, which brings me to the original question. Is theres a way around this or a different approach? 

            • 3. Re: How to set up script

              Set up an install OnTimer Script with your 15 hour interval in a different window hidden from the user. You can do this once for each irrigation well using a different hidden window for each timer. Then, the script run when the timer's interval runs out can include an Install OnTimer Script step with no parameters specified to cancel out that timer to keep it from repeating again in 15 hours or it can just close the concealed window after sending the email.

              • 4. Re: How to set up script

                I'm not sure of some of your details, but I tinkered a bit anyway. If you install the OnTimer into the same window with your normal layout/UI, it's possible to check if the record is locked and postpone the script.

                See my experiment here:


                • 5. Re: How to set up script

                  Ok.  I failed to mention that this runs a iOS device.  PhilModJunk would you be interested in showing me how that script might would look like.  Thanks Korry for your help looks like this would work as well.

                  • 6. Re: How to set up script

                    If filemaker go would support banners or alerts than that would take care of the need.

                    • 7. Re: How to set up script

                      Not sure how smoothly this will work on an iOS device but here's the idea:

                      Say you have 3 records, for 3 pumps with a value in a field called notifyTime in hours in each record:

                      Go To Record/Request/page [ first]
                          New Window
                          Install OnTimerScript ["ShowMessage" ; Parameter: Pumps::PumpNumber ; Interval: Pumps::NotifyTime * 3600 ]
                          Select Window [ Get ( FileName ) ]
                          Go to record/request/page [ next ; exit after last ]
                      End Loop

                      The script ShowMessage would look like this:

                      Show Custom Dialog ["Check Pump #" & Get ( ScriptParameter ) ]
                      Close WIndow

                      I'd have to test this on an iOS device to be sure, but I might need a select window step immediately prior to the show custom dialog step but I don't think so...

                      • 8. Re: How to set up script

                        Thanks for that. I have just now realized that scripts do not run on filemaker go when the app is in the background. Looks like it would need to be a hosted file and the script to run at that level. Am I correct on that?

                        • 9. Re: How to set up script

                          It would not need to be hosted, but the device would need to be kept from hibernating--or at least the user would have to bring the app to the foreground from time to time (and that might require a different script..)

                          Might be simpler just to use the Alarm app to set an alarm or timer for each pump....

                          • 10. Re: How to set up script

                            Yes, except the the database tracks other associated information other than the timers. I was trying to get away from duplicated entries using two different apps. I have not been able to make the script run when Go hibernates. If I understand your post this is possible. I have found this

                            "FileMaker Go will not hibernate if a file that is opened is running a non-abortable script whenever the close action occurs (home button, receive+accept incoming call). This applies to all opened files regardless of whether they were running a script or not. If the script is set to Allow User Abort [on], FileMaker Go will hibernate"

                            I set my script to Allow user abort [off] and have not achieved desired results. Maybe I don't understand what hibernate means. Is that when the device is on but Go is in the background, and, or the device is on but asleep?

                            • 11. Re: How to set up script

                              Hibernate is when the program stops running but without exiting the program.  Hence the reason your timer script is not running because FMGo is not running.  When you start FMGo you are returned back to the same location in your database.  If on a network FMGo will attempt to reconnect to the hosted database.

                              "FileMaker Go will not hibernate if a file that is opened is running a non-abortable script whenever the close action occurs (home button, receive+accept incoming call).  This is true but as soon as the script is complete then FMGo will hibernate.

                              I don't believe it can be done in FMGo because of the hibernate issue.  

                              I believe you will have to setup a hosted database that runs all the time on the server to accomplish this and then the email will be sent from the server.

                              • 12. Re: How to set up script

                                Ok sure.  I have not previously worked with scripts at the server level, and seem to be have problems. I notice some scripts steps say partially supported in server. Was wondering if I posted the file if someone would give me some pointers. thanks in advance


                                • 13. Re: How to set up script

                                  I did not say that it was possible to run a script while the FM GO is in hibernation. I suggested not letting the the device hibernate as there is a setting that can prevent this. The other option I mentioned would be to use a different script other than OnTimer that would check the current time each time your app leaves hibernation to determine which specified time intervals have now run down.