this is a real strange one and it took me quite a while to nuderstand what’s happening:
on an XPage I’m having an EditBox to collect Date values. Display type is “Date/Time”, Display format is “custom” with a German date pattern “dd.MM.yyyy”), and the “date/time picker pop-up” option is selected.
Now this field must be validated in a way that the user may not enter a date prior to the current week’s Monday. So in the Validation property / Validate Date/Time area I set the “Minimum” option to computed and entered the following code:
var tmpWD = @Weekday(@Today());
var earliestStartDate = @Today();
switch (tmpWD) {
case 1: //today is sunday
earliestStartDate = @Adjust(@Today(), 0, 0, 1, 0, 0, 0);
break;
case 2: //today is monday
earliestStartDate = @Today();
break;
default: //every other weekday
earliestStartDate = @Adjust(@Today(), 0, 0, (2 - tmpWD), 0, 0, 0);
break;
}
return earliestStartDate;
running the XPage and entereing a date that must be valid (this week’s monday i.e. July, 29 2009) I still receive a validation error.
If I go back into the designer, I now can see that the calculatuion for the “default” case soemhow has changed to
earliestStartDate = @Adjust(@Today(), 0, 0, (2 / tmpWD), 0, 0, 0);
so that now Division is performed instead of a Difference!!
Playing around for a while I observed that if I open the source editor and scroll down to the given code, and then call the code editor and entering the correct code (with 2 - tmpWd) and then close the code editor, the formula in the source editor immediately switches to the division again. Only if I change the code in the source editor itself and then save it, it remains to be a substraction.
Just to learn more about that, I temporarily entered a computed field and had it calculate its value through the same code. And here the arithmetical signs are NOT altered, so there must be a connection with the validation property.
I also tried this in various databases, but not in various Designer clients. So there is a chance that it’s my local client that’s gone berserk
Would someone please find the time and try this out for me? And possible write an SPR (as I can’t do it) in case it’s confirmed?
Thanks all