Due date should not be less than 24 hrs from current date on a catalog variable.

Madicherla Sri1
Tera Contributor

The date field should not allow users to fill less than 24 hrs from the current date and it should follow a defined schedule 

For example Schedule: Mon-Fri (8:00-19:00)Business hours

it should throw an error if the date is less than 24 hrs or out of business hours.

Looking for help.

Thanks in advance

 

1 ACCEPTED SOLUTION

Hi,

is script include client callable?

is the function being called properly?

share logs for this

var ajaxDateDiff = Class.create();
ajaxDateDiff.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    check5Days: function () {
        var answer;
        var valid = new GlideDateTime();
        valid.setDisplayValue(this.getParameter('sysparm_date'));
        
        gs.info('User value->' + valid);
        
        var schedule = new GlideSchedule('377f5e51db2e851040d8176a489619cc');
        var inSchedule = schedule.isInSchedule(valid);
        gs.info("Is in schedule->" + inSchedule);
        if (!inSchedule)
        {
            answer = 'false';
        }
        else
        {
            answer = 'true';
        }
        return answer;
    },

});

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

21 REPLIES 21

@Madicherla Srinivas 

Please mark my response as correct and close the thread.

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Madicherla Srinivas 

Please mark my script which worked for you as correct.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader