Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

isInSchedule not working

e_wilber
Tera Guru

For the script below, the schedule (shift 1)'s sys_id was checked countless times and we're pulling in the correct schedule that is 8-5 weekly, every M, T, W, T, F.

 

The test time we are testing with is at 10:00:00 which is well within the window of the shift but we keep getting a NO returned. Below is a screenshot of the calendar that SN is showing that the schedule is every workday.

 

Am I doing something wrong?

 

  var sched = new GlideSchedule('dde09e971b9b291041c20e91604bcb1d'); // Shift 1
  var schedTime = new GlideDateTime('06/26/2023 10:00:00');

  if(sched.isInSchedule(schedTime)){
    gs.print('y');
  }
  else {
    gs.print('n');
  }
 
e_wilber_0-1687791446017.png

 

6 REPLIES 6

@e_wilber 

 

I tried in my instance and it is providing accurate results for me

Any thing inside 8 am to 5 pm is returning true

 

Just FYI - 

setDisplayValue(String asDisplayed)

Sets a date and time value using the current user's display format and time zone.
 

 

Thank you Manhoman. The 'setDisplayValue()' was key to getting things working on my end