11 Replies Latest reply on Mar 13, 2017 1:06 PM by joshuaw07

    How do I Solve this Timer Problem?

    joshuaw07

      Problem:

      To simplify, I'll use "colors" to represent the field data needed.

       

      I have records that require a final determination (FD) in a particular field.

       

      Fields with an FD are "green".  All records are required to be marked "green" within 6 weeks.

       

      However, before a record reaches "green" it is possible for the record to have non FD value such as "blue."

       

      When the data entered into a field is "blue," I need a 2 week timer to be triggered.

       

      Once the 2 weeks elapses, if the the record's data has not reached "green," the record is automatically changed to "green."

       

      If the record reaches "green" before the 2 weeks elapses, the timer should be cancelled.

       

      I have never worked with server side scripts or with timer scripts. What is the most efficient way to obtain this automatic data entry?

       

      System:

      Our System is set up accordingly.

      -Mac Mini dedicated to running Filemaker Server 15 and is on and uninterrupted 24/7

      -Macbook Pro & iMac clients using Filemaker Advance 15 (for dev team) and Filemaker Pro 15

      -client computers only have access to Filemaker between 8a-8p.

      -all hardware running updated versions of macOS Sierra

        • 1. Re: How do I Solve this Timer Problem?
          wimdecorte

          If with "timer scripts" you mean the 'OnTimer" event trigger then this won't work here - at least not easily and I wouldn't recommend trying to force it.

           

          A server-side schedule is the best way to go.  Just create a script that:

          - finds the records that need to be evaluated

          - loop through those records and on each one make the proper determination and set the status

           

          When creating the script, in the Script Workspace make sure to set the compatibility view to "server" so that you can catch script steps that are not server-compatible.

          Also look at your OnOpen script(s) if you have any.  A server-side schedule will run any script triggered by OnFirstWindowOpen first before running the target script.

          • 2. Re: How do I Solve this Timer Problem?
            joshuaw07

            Thank you for this. Being that I'm relatively new to server side scripts, could you perhaps show me what the script logic would look like.

             

            also, on the server side script, how will it determine when 2 weeks are up.

             

            In my example when a record is entered as "blue" the server will run a script at 2 weeks. 

             

            Thanks for your help with this.

            • 3. Re: How do I Solve this Timer Problem?
              wimdecorte

              joshuaw07 wrote:

               

              Thank you for this. Being that I'm relatively new to server side scripts, could you perhaps show me what the script logic would look like.

               

              There's nothing different to the logic because of it running server-side.  It's exactly like you would do it normally.

              (with the caveat for the server-incompatible script steps).

              • 4. Re: How do I Solve this Timer Problem?
                wimdecorte

                joshuaw07 wrote:

                 

                also, on the server side script, how will it determine when 2 weeks are up.

                 

                 

                 

                Same as if you would do in a regular script.  I'm assuming that you record the date & time when data is entered into the relevant fields.  In your script you can then check that date against the current date and see if 2 weeks have passed.

                 

                if[ <the stored date> + 14 >= Get(CurrentDate)]

                --> do something

                • 5. Re: How do I Solve this Timer Problem?
                  philmodjunk

                  Better yet perform a Find for these records where the color is not green and today's date is 14 or more days padt the date recorded in the record.

                   

                  Finding "past due" grace periods, memberships or subscriptions are often processed in this manner.

                  • 6. Re: How do I Solve this Timer Problem?
                    joshuaw07

                    This is close, Now I need the field to automatically change the color "blue" (in written form that is, i don't need the field to be formatted to the color green) to "green"

                     

                    how is this accomplished?

                    • 7. Re: How do I Solve this Timer Problem?
                      philmodjunk

                      Once you have performed a find, the script can update this field in each found record using either a loop or replace field contents. With either method, this is best done at a time when other users are not modifying records in the same table. If they have one of these records open for editing at the time the script will not be able to update a field in that record. Thus, this is best done via a server schedule "after hours", if possible.

                       

                      It is also possible to make this field an unstored calculation field that simply uses a calculation to change what text appears in the field.

                      • 8. Re: How do I Solve this Timer Problem?
                        joshuaw07

                        Thank you this is it. I'm close. One last follow up question and I think I'll have it,

                         

                        How do i enter the find criteria to return records that are 14 days or older

                        • 9. Re: How do I Solve this Timer Problem?
                          joshuaw07

                          I have the color part squared away and working

                           

                          But based on the records modification timesamp i need anything older than 14 days (and the color) to be found. I'm just having trouble piecing together the find criteria for the modification timestamp.

                          • 10. Re: How do I Solve this Timer Problem?
                            wimdecorte

                            record mod timestamp may not tell you exactly when that one field was set to blue though; which is why I indicated that you may need keep a separate timestamp field that only gets set when the 'blue' field gets changed.

                            • 11. Re: How do I Solve this Timer Problem?
                              joshuaw07

                              wimdecorte thanks for help, but philmodjunk 's approach worked for me.

                               

                              I got the script that runs server side that transitions all records to "green" if they remain blue after 14 days.

                               

                              Actually in the script screen shot you will see I changed the colors to  "black" and "yellow" to fit my actual need as green and blue were just for

                               

                              Thanks for your help!!!!

                               

                              Screen Shot 2017-03-13 at 4.05.37 PM.png