cronJob resets field content

I am using a cronJob to update two clocks that show local and Zulu (UTC) time.

When I create a new record and type something into a field, that field gets wiped out, when the cronJob fires.

If I change the field content of an existing record, the content is reset to the original content when the cronJob fires.

This only seems to happen when I output ‘globals.timeUTC’ into a field. If I use a label to display the datetime object, the previous behaviour is not observed.

Feature or bug? Don’t use fields when updating data in cronJobs?

BTW: I haven’t figured out yet on how to display the time portion of the datetime object in a label. %%globals.timeUTC%% only shows the date portion. I have messed with this all day so any advise would be highly appreciated.

here is the cronJob:

// get current time
globals.timeLocal = new Date();

// get time zone offeset in minutes
var tzo = globals.timeLocal.getTimezoneOffset();

// multiply by 60 seconds * 1000 milliseconds
tzo = tzo * 60000;

// calculate UTC/GMT/ZULU
globals.timeUTC = globals.timeLocal + tzo;

what fields are you talking about ?

I see that you only touch globals. as far as i can see.

What happens if you run that script youreself without a cron job? Just pressing play..

Can you give me a bit more what you exactly do? (sample solution?)

jcompagner:
what fields are you talking about ?

text fields connected to global date objects in a controller showing ZULU and local time.

I see that you only touch globals. as far as i can see.

that is affirmative.

What happens if you run that script youreself without a cron job? Just pressing play..

same thing - it wipes out whatever i type into that field. my guess is that the (time) text fields take focus for updating the time and then something goes wrong when focus gets returned to my active text field.

Can you give me a bit more what you exactly do? (sample solution?)

On it’s way to you. Thanks a lot for your quick response. Bedankt!

I am going to deploy within a weeks time. I need the cron jobs to show local and zulu time as well as pushing messages to the clients on a regular basis. Is there a solution in sight?

Again the problem is that when a cronJob changes a global variable that is displayed on a form (local and zulu time in this case) , the current field I am editing forgets everything I have typed into it since it was last saved.

This is the code I am calling every minute:

// get current time
globals.timeLocal = new Date();

// get time zone offset in minutes
var tzo = globals.timeLocal.getTimezoneOffset();

// multiply by 60 seconds * 1000 milliseconds
tzo = tzo * 60000;

// calculate UTC/GMT/ZULU
globals.timeUTC = globals.timeLocal + tzo;

// go to the next MOTD
var MOTD = forms.allMOTD.controller.getSelectedIndex();
if (MOTD == forms.allMOTD.controller.getMaxRecordIndex())
{
	MOTD = 0;
}
forms.allMOTD.controller.setSelectedIndex(MOTD+1);

I display globals.timeUTC and globals.timeLocal as fields in my custom controller.

Here is a modified global method that is executed by the scheduler:

// get current time
forms.navClock.timelocal = new Date();
// calculate UTC/GMT/ZULU
forms.navClock.timeutc = forms.navClock.timelocal + globals.timeZoneOffset;

// go to the next MOTD
var MOTD = forms.allMOTD.controller.getSelectedIndex();
if (MOTD == forms.allMOTD.controller.getMaxRecordIndex())
{
	MOTD = 0;
}
forms.allMOTD.controller.setSelectedIndex(MOTD+1);

I am using db fields (timeutc, timelocal) in a table with only one record instead of the global datetime objects (globals.timeLocal, globals.timeUTC). It works for now but it’s not pretty.

Hope this helps to find the issue.

Happy New Year!

it is a while when i looked at this. So i can’t remember exactly anymore what really happend. But the best thing is to call controller.saveData() first thing in the cornjob.
Because when you change a value it does a fire that will reset all values.
But can you test with the latest beta of 2.2? Do you still have this problem? Also i am willing to look again at it to see if we can fix it somehow a bit better.. Can you send me a current sample solution?

I’ll email you a sample. Did this forum have attachments?