10 Replies Latest reply on Apr 11, 2014 7:42 AM by rayhenriette

    Re: include clock counter on report

    rayhenriette

      Hi, I am creating a fm database that connect to the company sql server using external SQL data source. Using this database, I wish to create a report that show only live jobs as status change. It needs to have a clock counter on it to show how long each job has been on a status, and time left to move to next status. A countdown clock showing time remaining per job is very important. This report is to be display on a big tv so that staff can view active jobs. Can anyone advice how i can get the "time remaining" counter working.

       

      Thanks

       

      Ray

       

      treport_1.JPG

        • 1. Re: include clock counter on report
          GAmstutz

          There are several ways to accomplish this... you can control the timer from a client computer or from the server.


          If you have a client that is dedicated to displaying the job board on a big screen, then you might consider client side control.

           

          Simply write a script that updates your 'time remaining" field(s) (Table::EstimatedFinishTime - Get(CurrentTime)), then have some other event start your timer by setting another script that calls "Install OnTimer Script" which calls your first script that updates your time remaining field.

           

          As long as that window remains open, the clock will then be updated.  When you want to stop the clock, call Install OnTimer Script again but don't pass it a script.

           

          It wasn't clear from your image -- wasn't sure if your time remaining was min:sec or hours:min.  If the former, then call the OnTimerScript with 1 second intervals.  If it's HR:MiN, then call it with 60 second intervals.

           

          Hope this helps!

          - Gary

          • 2. Re: include clock counter on report
            DamianKelly

            If you are going to display a second count down I would consider a webviewer, much trickier to do but if you are displaying a lot of records and constantly run an ontimer trigger every second you are going to hammer the server.

            • 3. Re: include clock counter on report
              GAmstutz

              How would that "hammer the server"?  If it's run on the client side, it shouldn't have hardly any impact on the server -- he could use a simple variable in memory on the client, too, for each record without changing any fields, such as:

               

              $$timeRemaining[rec] = $$estFinishTime[rec] - Get(CurrentTime)

               

              and display the counter in a Merge Field on the job board, like this:

               

              "Time remaining: <<$$timeRemaining[rec]>>"

               

              Webviewer would work, but seems like overkill when a simple global variable with MergeField display should work fine.

               

              But even you update a 'normal' field, FileMaker Server can easily handle one simple script per second with just updating one field in just a few records at a time.

               

              - Gary

              • 4. Re: include clock counter on report
                DamianKelly

                How are you going to refresh the display? With a refresh window scriptstep? Because you can not refresh an individual element within a layout filemaker client will check with server to see if anything has changed, thus hitting the server.

                 

                Its upto you but personally I try to avoid hitting the server unnessarily. A web viewer is a little trickier but is easy to make entirely client side. And like I said if you are showing a lot of records constantly updating then it might be an issue.

                 

                Experience has taught that 'just an onTime trigger here and there' lead to a slow system.

                 

                Pretty trivial to include a web page based on this:

                http://www.gieson.com/Library/projects/utilities/countdown/

                 

                Ten minutes work, hack in the passed values and you are away........

                 

                I will take down the images that are hosted on my server at some random point in the future.

                 

                I will add support for hours, minutes and seconds later if i have time

                 

                Message was edited by: DamianKelly I have added a new version of the file. This one uses the hours, minutes and seconds. Copy the image directory from my server and put it somewhere safe on your own webserver or get it from the link above.

                • 5. Re: include clock counter on report
                  rrrichie

                  A webviewer would be my option too.  Using Javascript you can make a small counter with just a few lines of code.

                  You could also use a library, but that would be overkill if you ask me.  It really depends how many counters you want to display...

                   

                  Just put the following in a field and make a webview point to the field.  Construct the time needed at the var=min and var=secs...

                   

                   

                  <!DOCTYPE html>

                  <html>

                  <head>

                  <script>

                  // Set the time values here with variable or field values for example

                      var mins = 10;    

                      var secs = mins * 60;

                     

                  // Init  

                      var mySeconds = 0;

                      var myMinutes = 0;

                  // Set Countdown Interval 

                      setTimeout('Decrement()',1000);

                   

                      function Decrement() {

                          myMinutes = Math.floor(secs / 60);

                          mySeconds = secs % 60;

                  // format 00:00       

                         myMinutes= (myMinutes <= 9)?"0" + myMinutes :myMinutes ;

                         mySeconds=(mySeconds <= 9)?"0" + mySeconds:mySeconds;

                  // Countdown;

                          secs--;

                  // Update on screen

                          document.getElementById("timer").innerHTML = myMinutes + ":" + mySeconds;

                  // Set Next TimeOut

                          if(secs !== -1) setTimeout('Decrement()',1000);

                      }

                   

                  </script>

                  </head>

                   

                  <body>

                  <span id="timer"></span>

                  </body>

                  </html>

                  • 6. Re: include clock counter on report
                    GAmstutz

                    How are you going to refresh the display? With a refresh window scriptstep? Because you can not refresh an individual element within a layout filemaker client will check with server to see if anything has changed, thus hitting the server.

                     

                    To answer your question, I would use "Refresh Object".  Then name your text element and all it within your "Refresh Object" command.  Do that in the same script that contains your time calculation (in the script that is called once a second).  I've done this and have seen no slow down of the system.  Of course, if you add hundreds of timers, it will make a difference, but all rows can be updated in the same timer.

                     

                    As far as I can tell, the server isn't hit when you call "Refersh Object" from within a timer, and you use that to redraw the merge varible within the text object.  Am I missing something?  I didn't test it, but can anyone else confirm or deny that Refresh Object does not hit the server if called repetedlly on a text objcect in a client window?

                     

                    Rememner the OP is displaying this on a job board on a big screen.  It's unlikely he'll be using that one client for anything else other than the job board display.  I still vote for my simpler two line script solution:

                     

                    Set Variable [$$cTime; (Add your calculation here)]

                    Referesh Object: [ Object Name: "CTime"]

                     

                    Then name your text object that contains the Merge Variable: "CTime".

                     

                    Finally create another script that runs this script in a timer every minute (or second if necessary).

                     

                    - Gary

                    • 7. Re: include clock counter on report
                      rrrichie

                      Haha, a big ROFL here, since when is the refresh object present in FMP?  That is the simplest solution indeed!  I always used to refresh the screen which sometimes annoys a user cause it resets certain things...

                       

                      Thank you Gary!

                       

                      (busy changing scripts right now... )

                      • 8. Re: include clock counter on report
                        DamianKelly

                        I should go to the bottom of the class, I only reread the feature list on 13 the other day too . I even stuck a note in my notebook to look into using the new scriptstep to optomise some stuff I had worked on in 12.

                         

                        Am testing currently but initial indications are good (just watching little snitch to see if there is traffic between my desktop and server). Running CocoaPacketAnalyzer on it to be certain, will let you know in a minute...

                        • 9. Re: include clock counter on report
                          DamianKelly

                          I dont think it touches the server if the object is updateable on the client. I set a variable equal to itself plus 1 in a loop pausing briefly. The traffic to FileMaker server was no different before it ran to during, so it looks like it knows :-)

                          • 10. Re: include clock counter on report
                            rayhenriette

                            Thanks to all, I will try out your solution and advise how i get on.

                             

                            Cheers

                             

                            Ray