Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 2506 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

I might be reviving an old topic, but wanted to share what I have come with to run a script at a specified time of day. I have no Filemaker Server, I am running Filemaker Pro Advanced 11.

In my example I want to run script "Export_DL4_Call" at 23:00:00 every day which exports data from file, let's call it "File1".  I created another file, let's call it File2 on which I calculate the schedule of time and from it I call the script on File1.

At first I tried with windows scheduler but it was not reliable at all.

On File2 create fields "Time1" and "Schedule_Time" both as text. Create a script "Schedule_Time_24h" which runs every 24h with following steps:

Set Field [File2::Schedule_Time; 86400]

Install OnTimer Script ["Export_DL4_Call"; Interval: File2::Schedule_Time]

This will obviously run the script every 24h, but if the file opens at 7:00 then it will run it every day at 7:00, so I created a second script as follows

Create a script, which runs when file is open, "Schedule_at_23" with these steps:

Set Field [File2::Schedule_Time; ""]

Set Field [File2::Time1; Get ( CurrentTimeStamp )]

Set Field [File2::Schedule_Time; Let ( [ hour2 = 23; min2 = 0; sec2 = 0; hour1 = Hour (File2::Time1); min1 = Minute (File2::Time1);
sec1 = Seconds (File2::Time1) ]; ( sec2-sec1 ) + ( min2 -min1 )*60 + ( hour2 - hour1)*3600 )]

Pause/Resume Script [duration (seconds): File2::Schedule_Time

Perform Script ["Schedule_Time_24h"]

The reason I am running these scripts on a second file, is because Install OnTimer Script will stop if the windows from which it runs closes, so to avoid that, I am running it on a different file which is not accessible to users.

Edited by Toni
correction
Posted

After some testing, I came with a better way because that Pause/Resume step of script is really annoying.
Posting here only the script steps:

"Schedule_Time_24h" steps:

Install OnTimer Script []

Perform Script [Export_DL4_Call]

Set Field [File2::Schedule_Time; 86400]

Install OnTimer Script ["Export_DL4_Call"; Interval: File2::Schedule_Time]

"Schedule_23_h" steps:

Select Window [Current Window]

Adjust Window [Hide]

Set Field [File2::Schedule_Time; ""]

Set Field [File2::Time1; Get ( CurrentTimeStamp )]

Set Field [File2::Schedule_Time; Let ( [ hour2 = 23; min2 = 0; sec2 = 0; hour1 = Hour (File2::Time1); min1 = Minute (File2::Time1);
sec1 = Seconds (File2::Time1) ]; ( sec2-sec1 ) + ( min2 -min1 )*60 + ( hour2 - hour1)*3600 )]

Install OnTimer Script ["Schedule_Time_24h"; Interval: File2::Schedule_Time]

This topic is 2506 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.