I've not yet found a comprehensive tutorial on the subject (would be an excellent idea) and references to date related matters are scattered and not indexed in the docs. Doing searches in ServoyTalk produces way too many hits to be useful.
I have a datetime field "calldate" where users can identify the next time a client should be called. That field has the following onFocusLost method attached to prevent users from scheduling a call in the past.
About 95% of the time or more this routine works perfectly. However, erratically I get an error message saying that "calldate" is not defined.
In this particular instance I had just come back out of Design mode, had re-established the globals and clicked in a blank calldate field. I've done this many times before without error, but this time I get the error message.
A few days ago I added a saveData() instruction right at the top of this routine to prevent exactly this error occurring. Cut down the incidence of this error way back, but obviously hasn't eliminated it.
Can anyone spot the coding error?
- Code: Select all
controller.saveData();
if ( calldate )
{
var d1 = new Date(calldate);
var d2 = new Date();
var diff = plugins.it2be_tools.dateDifference(d1, d2, 5);
if ( diff < 0 )
{
// application.output('callsUtility.exitCallDate calldate = ' + calldate);
calldate = null;
controller.saveData();
var title = i18n.getI18NMessage('7office.dlg.error');
var msg = i18n.getI18NMessage('7office.dlg.cr.nextcallerror');
var btn = plugins.dialogs.showQuestionDialog(title, msg);
// 'You cannot schedule a "next call" to happen in the past.'
calldate = application.showCalendar();
}
}