Business days Issue

Dave_p
Giga Guru

Hi,

I am in a scenario where I should i be allowed to select next 15 business days from today. I tried getting some help from community, but it didn't work. Kindly help.

 

1.png

 

2.png

 

3.png

 

4.png

 

5.png

 

6.png

 

(function executeRule(current, previous /*null when async*/ ) {

    var schId = "090eecae0a0a0b260077e1dfa71da828";
    var sch = new GlideSchedule(schId);
    var now = new GlideDateTime();
    var next15Days = sch.add(now, 15, "business");
    var dateThreshold = new GlideDateTime(next15Days).getDate();
    if (current.desired_completion_date < dateThreshold) {
        gs.addErrorMessage("Date must be after 15 business days.");
        current.setAbortAction(true);
    }

})(current, previous);

 

Regards

Suman P.

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@Dave_p 

you should use onChange catalog client script rather than BR

check this and enhance

Variable Date no less than 5 business days 

Auto-populating and validating date fields 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

Hi Dave - 43200 is how many seconds are in 12 hours(the schedule of 8-8 is 12 hour business days).  

View solution in original post

10 REPLIES 10

Hi Dave - 43200 is how many seconds are in 12 hours(the schedule of 8-8 is 12 hour business days).