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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use onChange client script and GlideAjax and use schedule calculation in script include

Regards
Ankur

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

Cloud you please help me with the script.

I was confused about where to use the schedule in my script.

you would require to use schedule for this

below links should be helpful

https://community.servicenow.com/community?id=community_blog&sys_id=314e26addbd0dbc01dcaf3231f961986

https://community.servicenow.com/community?id=community_question&sys_id=d231964bdb87ab005d782183ca96...

Regards
Ankur

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

Unable to find a required answer.