Auto-Refresh Add-On

Notes on our latest calendar for FileMaker 13,: DayBack
Posts: 5
Joined: Fri Jul 07, 2017 4:15 am
PostPosted: Thu Sep 21, 2017 3:19 am
I was looking the other day for some calendar auto refresh ideas here.
I have seen some solution to set calendar with auto refresh and swap resources every 15 sec or so, on the big display TV, but none for every user in the system.

We have found on many occasions that two users would be looking on the same even seeing different content. One of the users for example would have calendar opened for few minutes ( with old data still on ) and not realised the change has been made to it. This situation was unacceptable for us.

So I have implemented a quick auto-refresh using 3 scripts, ExecuteSQL and Modification Timestamps in each source:
    * Script 1 triggered on layout entry to run script 2 (OnTimer) every 60 sec
    * Script 2 runs 1 SQL query for each source/calendar for changes within last 60-70 sec. (based on UTC timestamps or standard timestamp ) if change would be found it would call "Refresh Calendar" script, if not found then to exit
    * Script 3 triggered on layout keystroke - if ESC is pressed to ask if refresh should be stopped, if so to install ontimer script without time and script set to stop the previous one

One thing I was afraid of; what if a user would be amending other event at the same time when the refresh is launched. It turns out, because the event popup window is created as an javascript object, screen refresh does not disregard it. Popup stays where it was with all the details user was entering.

Bare in mind I had to remove SQL queries from the code due to security reasons as well as SQL injection alerts on this forum

SCRIPT 1
Code: Select all
# Purpose: Run on layout entry. To set recurring script every 60 sec to check if there are any changes made to the calendar data sources
# Layout: Calendar main layout
# Trigger(s): Main calendar triger on layout entry
#  To Stop it - select top bar and pres ESC

#
If [ Get(SystemPlatform) = 3 ]
   Exit Script [ Text Result:    ]
End If
#
Install OnTimer Script [ “Script 2” ; Interval: 60 ]


SCRIPT 2
Code: Select all
# Purpose: Check if any change made within last 70 seconds, if so refresh calendar on screen, except iOS
# Layout: Calendar main layout
# Trigger(s): Run onTimer call Every 60 seconds ro layout triger script : “Refresh Calendar”
# Parameter(s): None
#  To Stop it - select top bar and pres ESC
# --------------------------------------------------------------------------------------------------------------------------------
#
Set Variable [ $d ; Value: Get(CurrentDate) ]
#  so on change made to any of below events would refresh screen
Set Variable [ $t ; Value: Get(CurrentTime)-70 ]
#
# Site Visit check - Source 1
Set Variable [ $changeMade ; Value: ExecuteSQL(... ) ]
# Schedules Check - Source 2
Set Variable [ $changeMade ; Value: $changeMade + ExecuteSQL(... ) ]
# Holidays Check - Source 3
Set Variable [ $changeMade ; Value: $changeMade + ExecuteSQL(... ) ]
#
If [ $changeMade > 0 ]
   Perform Script [ “Refresh Calendar” ]
End If


SCRIPT 3
Code: Select all
# Purpose: to stop Calendar refresh onTimer installed script by pressing ESC
# Layout: Calendar main layout
# Trigger(s): on layout keystroke
# Parameter(s): None
# this script is invoked every time you press Esc key on the Calendar layout - set as a layout triggered by keystroke
# it waits for ESC keystroke '27' to ask if you want to continue or stop the original script
# In order to stop ontimer script you need to call new empty ontime script and then halt it
# ------------------------------------------------------------------------------------------------------------------------------------
#
If [ Code(Get(TriggerKeystroke)) = "27" ] 
   Install OnTimer Script []
   Show Custom Dialog [ "Info" ; "Stop Refreshing?" ]
   #
   If [ Get(LastMessageChoice) = 2 ]
      Install OnTimer Script [ “Script  2” ; Interval: 60 ]
   Else
      Halt Script
   End If
   #
End If
SeedCode Staff
SeedCode Staff
Posts: 357
Joined: Tue Nov 08, 2016 1:54 pm
PostPosted: Thu Sep 21, 2017 12:33 pm
Hi Booree,

Great job on these scripts! Is this something you'd be willing to let us post on our blog (crediting you, of course)?

Regards,

KC
Posts: 5
Joined: Fri Jul 07, 2017 4:15 am
PostPosted: Fri Sep 22, 2017 2:06 am
kcembrey wrote:Hi Booree,

Great job on these scripts! Is this something you'd be willing to let us post on our blog (crediting you, of course)?

Regards,

KC


Thanks for your nice comment.

If you think my solution is worth it please go ahead with posting it on your blog.

Greg

Return to DayBack Calendar for FileMaker

Who is online

Users browsing this forum: No registered users and 2 guests

cron
(855) SEEDCODE
[email protected]
Follow us: