Date Validation error in Record Producer
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 01:16 PM
Hello folks!
I have a record producer with the field “Start date and End date”, which is validated by the following Catalog client script:
function onSubmit() {
if (g_scratchpad.areDatesValid) {
return true;
}
g_scratchpad.actionName = g_form.getActionName();
g_scratchpad.areDatesValid = false;
var variableDescriptor = g_scratchpad.coi.variableDescriptor;
var SUBCATEGORY_OUTSIDE_EMPLOYMENT = variableDescriptor.conflictTypes.outsideEmployment.id;
var SUBCATEGORY_BOARD_SERVICE = variableDescriptor.conflictTypes.boardService.id;
var CONFLICT_TYPES = [SUBCATEGORY_OUTSIDE_EMPLOYMENT, SUBCATEGORY_BOARD_SERVICE];
var conflictType = g_form.getValue('conflict_type');
var startDate = g_form.getValue('start_date');
var endDate = g_form.getValue('end_date');
if (CONFLICT_TYPES.indexOf(conflictType) > -1 && startDate && endDate) {
var coiAjax = new GlideAjax('sn_lg_coi.LegalCoiAjax');
coiAjax.addParam('sysparm_name', 'compareDates');
coiAjax.addParam('sysparm_start_date', startDate);
coiAjax.addParam('sysparm_end_date', endDate);
coiAjax.setScope('sn_lg_coi');
coiAjax.getXMLAnswer(function(answer) {
var result = JSON.parse(answer);
if (result === 1) {
var errorMessage = getMessage('Start date must be earlier than the End date.');
g_form.addErrorMessage(errorMessage);
return;
}
g_scratchpad.areDatesValid = true;
g_form.submit(g_scratchpad.actionName);
});
} else {
return true;
}
return false;
}
The problem is that when I put these specific dates when filling the form, I get this error and it does not allow me to send it:
Any help is greatly appreciated!
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 12:32 AM
may i know, what this method is doing ?
return JSON.stringify(DateUtils.compareDates(startGlideDate, endGlideDate));