Event Schedule Not working Properly

ramesh_r
Mega Sage

I want to check if the given date is falling in the Business days or not, for I created one schedule in the cmn_schedule and I used the below code but it's not working as expected

 

My expectation it should return true for all the time from 00 to 24

 

'08/07/2023 00:00:00'-- its returning False

'08/07/2023 5:00:00'--- its returning True

 

var startDate = new GlideDateTime('08/07/2023 00:00:00'); 

var grSchedule = "a2fe3d39977d6110318dbf8fe153af80"

var schedule = new GlideSchedule(grSchedule);
var d = new GlideDateTime(startDate);
gs.info(schedule.isInSchedule(d))

 

ramesh_r_0-1691558797302.png

 

ramesh_r_1-1691558835854.png

 

 

1 REPLY 1

Samaksh Wani
Giga Sage
Giga Sage

Hello @ramesh_r 

 

Actually when you select All day inside the schedule it will consider the Time till 23:59:59, May be for 00:00:00 it is not considering, In that case you can mention a Special case in your script.

 

var startDate = new GlideDateTime('08/07/2023 00:00:00'); 

var grSchedule = "a2fe3d39977d6110318dbf8fe153af80"

var schedule = new GlideSchedule(grSchedule);
var d = new GlideDateTime(startDate);

var time = d.getTime();

if(time=='00:00:00'){

gs.info(true);

}

else{
gs.info(schedule.isInSchedule(d))

}

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh