Date Validation error in Record Producer

Aram Sosa
Tera Expert

Hello folks!
I have a record producer with the field “Start date and End date”, which is validated by the following Catalog client script:

 

AramSosa_1-1713903213032.png

 

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:

AramSosa_2-1713903253092.png

 

Any help is greatly appreciated!

5 REPLIES 5

may i know, what this method is doing ?

 return JSON.stringify(DateUtils.compareDates(startGlideDate, endGlideDate));