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

Dave_p
Giga Guru

Hi @booher04,

 

I understood the code perfect but one small thing. What is 1000 please?

 

Regards

Suman P.

@Dave_p 

Thank you for marking my response as helpful.

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

@Dave_p 

1 second is 1000 milli second

So it's converted to be used in GlideDuration

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

Dave_p
Giga Guru

Hi @Ankur Bawiskar,

 

I have short term memory. Can you please help how did @booher04 get 43200.

 

1.png

 

Regards

Suman P.

Dave_p
Giga Guru

Hi @booher04 , Can you please help me with how did you get 43200.

 

1.png

 

Regards

Suman P.