Opening scripts on server vs opening scripts on client

I need to run an opening script when Servoy Server is started AND a separate opening script each time Servoy Client is launched.

Is this possible, and how?

Each is a Cron scheduler routine running round midnight. One goes through all task records noting what was scheduled for completion yesterday and rolling it over to today. The other needs to visit the global date field for each user who has left their Servoy Client up and running and reset that date to today. In the morning users should see the current date, not yesterday or some other date.

One Cron needs to run just once on all records. The other needs to run for as many clients are currently running at midnight.

Possible? How?

Kind regards,

Morley,

Cron jobs that run with the scheduler plug-in run ON THE CLIENT ONLY.

You would just create a job that ran at midnight when you open your solution (if the client was open it would run, if not it wouldn’t).

Then, perhaps have a “flag” field in your DB for “updated” and then in your method you can do a FIND for all the records due yesterday where the “flag” field is NOT 1. Then loop through and update.

bcusick:
Cron jobs that run with the scheduler plug-in run ON THE CLIENT ONLY.

You would just create a job that ran at midnight when you open your solution (if the client was open it would run, if not it wouldn’t).

Then, perhaps have a “flag” field in your DB for “updated” and then in your method you can do a FIND for all the records due yesterday where the “flag” field is NOT 1. Then loop through and update.

Not the functionality I’m looking for.

I want to turn the Server on and then have a routine that runs DAILY shortly after midnight just once whether or not any users are logged on or not. Your flag approach won’t work if there are no clients logged on at midnight.

Surely there must be a way to have daily housekeeping routines run on all records, all clients whether or not they’re logged on or not at a low traffic time of day. Please confirm whether this is the case or not. If not, I’m startled this issue has not come up before.

Kind regards,

Hi Morley,

Don’t be “startled”… :D

Most people do these types of things with stored procedures on their backend database - and it’s configured completely outside the Servoy environment.

Hi Morley,

for your global problem: why do you set the current date in a global? I find it a little odd to have (and maintenance) a global just to show the current date. Couldn’t you just use a calculation that will do something like

var today = new Date();
return today;

and place that on your form?

Regarding your other problem: if I understand you right, you want to show reminders or something like that, that might have been forgotten in the past. If your user wants to see the list of reminders, couldn’t you just transfer all left overs of the past right then?

Patrick

patrick:
Hi Morley,

for your global problem: why do you set the current date in a global? I find it a little odd to have (and maintenance) a global just to show the current date. Couldn’t you just use a calculation that will do something like

var today = new Date();

return today;




and place that on your form? 

Regarding your other problem: if I understand you right, you want to show reminders or something like that, that might have been forgotten in the past. If your user wants to see the list of reminders, couldn't you just transfer all left overs of the past right then?

Not quite. The user should be able choose which tasks are scheduled for today, tomorrow, two weeks from today, etc., as they please. Therefore a global field holding their current choice.

However, for users who leave the computer up all night, they should be returned to the current day at midnight. They should not be left assuming they’re looking at the current day when in fact it’s now pointing to yesterday.

Rather than leaving it to users to themselves do a rollover of people uncalled yesterday to today (many just won’t think to do it consistently) I’d prefer to have Servoy do that for them automatically.

Well as long as they have that client open all the time then a Servoy conjob will do the trick.
This cronjob is client specific.

Not quite. The user should be able choose which tasks are scheduled for today, tomorrow, two weeks from today, etc., as they please. Therefore a global field holding their current choice.

That sounds like those records are shown via a relation using that global? If that is the case, why couldn’t you still use my calc for your relation? Of course you would have to figure out, when that relations is reloaded and the calc updated…

But for that part, as Bob already noticed, you have a solution anyway…

You would just create a job that ran at midnight

That can make sure your global is updated, although that appears a little as being a strange procedure… I would look more into onShow, onLoad, onSolutionStart etc. events to make sure nothing gets forgotten.