Validating globals to activate global relations

I built a form with 6 portals, each based on a global relation that show selected operator’s appointment from Monday to Saturday (the typical relation is:

globals.day1 = appodate
globals.operator = operatorid

One thing is driving me crazy: the portals are not updated if I don’t enter the global date field and click out.
I set up a method that set the time part to “00:00:00”, but the enter/exit field is always needed: it seems that values aren’t actually stored in the global until the cursor leaves it.
I tried to simulate this behaviour, but using requestfocus and savedata doesn’t solve the problem.
Another bizarre behaviour: if I set the date to “15-8-2004” and put 2 instances of the same global field, one formatted as “dd” and the other as “dd-MM-yyyy HH:mm:ss”, entering the first and leaving it causes the second to change the value to “9-1-1970 00:00:00”.

Any help appreciated :-)

yes you need to get out of the field (so that the data is commited)
you say that you use requestFocus and saveData.. But who does trigger does thigs? When do you call those 2? SaveData should do the trick anyway.

How do you exactly set the global? Through a Calendar field?

If you set a data that only have partial formatting then the data will not be completely set! This is because only the ‘dd’ part is stored, the rest is thrown away.
I don’t know currently why you get 9-1 if you put 15-8. I will investigate this.

i tested this:

If you have a field that only displays the ‘dd’ then you should make this field uneditable, because if you make it editable then you can type in 10 or 15 and what part do we then take for the rest of the date?

If if make the date calendar uneditable then the date you select from the date chooser is used. And only dd is displayed.

IF i make a global relation on a date. And i change the date through the date chooser the portal is updated directly. I don’t have to klik out of the field.

jcompagner:
yes you need to get out of the field (so that the data is commited)

But I’m setting the values using a method. I’m already “outside” the field.
The problem is that I need to enter and exit the field, to make the relations work.

jcompagner:
you say that you use requestFocus and saveData.. But who does trigger does thigs? When do you call those 2? SaveData should do the trick anyway.

How do you exactly set the global? Through a Calendar field?

Unfortunately, SaveData doesn’t help: using a method, the data don’t seem really committed until I enter the fields.

jcompagner:
If you set a data that only have partial formatting then the data will not be completely set! This is because only the ‘dd’ part is stored, the rest is thrown away.

But if I set the value of a global date field using a method that sets it to 12-08-2004 00:00:00, I would expect this value is actually stored and usable for relations, am I wrong?

jcompagner:
i tested this:

If you have a field that only displays the ‘dd’ then you should make this field uneditable, because if you make it editable then you can type in 10 or 15 and what part do we then take for the rest of the date?

If if make the date calendar uneditable then the date you select from the date chooser is used. And only dd is displayed.

IF i make a global relation on a date. And i change the date through the date chooser the portal is updated directly. I don’t have to klik out of the field.

I tried, but it doesn’t work: setting fields as uneditable calendars doesn’t cause the update of the portal.
But it wouldn’t solve my problem if it worked too: I have to set values using a method: I can’t ask the user to click on 6 globals to select the right day in a weekly agenda…;-)

wait
you are setting through a method?
Then the global is updated immediantly and the portal must be filled in right away.

Then i can only think of one thing and that is when you do this:

globals.youredate = xxxxxx

that xxxxx is a date but with a time portion ect so that it doesn’t really match the relation.
And because you then click in and out of a field it updates the global again without a time portion (because of the format or something) and then the relation is there.

jcompagner:
wait
you are setting through a method?
Then the global is updated immediantly and the portal must be filled in right away.

Then i can only think of one thing and that is when you do this:

globals.youredate = xxxxxx

that xxxxx is a date but with a time portion ect so that it doesn’t really match the relation.
And because you then click in and out of a field it updates the global again without a time portion (because of the format or something) and then the relation is there.

Here is the method i’m using: maybe there’s something wrong I didn’t notice.

var Today = new Date();

switch(Today.getDay() )//sets the beginning of the week (Monday first)
{
case 0:
globals.weekbeginning = Today.setDate(Today.getDate()+1);
break;
case 1:
globals.weekbeginning = Today.setDate(Today.getDate());
break;
case 2:
globals.weekbeginning = Today.setDate(Today.getDate()-1);
break;
case 3:
globals.weekbeginning = Today.setDate(Today.getDate()-2);
break;
case 4:
globals.weekbeginning = Today.setDate(Today.getDate()-3);
break;
case 5:
globals.weekbeginning = Today.setDate(Today.getDate()-4);
break;
case 6:
globals.weekbeginning = Today.setDate(Today.getDate()-5);
break;
default:
break;
}
//sets the days of the agenda, from Monday to Saturday
var iniziosett = globals.weekbeginning 

iniziosett.setHours(0)
iniziosett.setMinutes(00)
iniziosett.setSeconds(00)

iniziosett.setDate(iniziosett.getDate());
globals.giorno1 = iniziosett


iniziosett.setDate(iniziosett.getDate()+1);
globals.giorno2 = iniziosett
//and so on...

The method must identify the first day of the week and set the globals. If it worked, there would be no other interaction with those fields.
If I place copies of the global fields formatted as dd-MM-yyyy HH:mm:ss, they show values like:
9-8-2004 00:00:00
10-8-2004 00:00:00
etc
Hope it helps to focus the problem. :)

try this extra line

iniziosett.setMilliseconds(0);

jcompagner:
try this extra line

iniziosett.setMilliseconds(0);

it worked. :D
Only in one case the portals still didn’t update: when I switched to next or previous week, but adding a step that changed the value of globals.operatorid seems to do the trick.

Thanks Johan