clarification on Glideschedule API

kummara _siva
Tera Contributor

Hi All,

 

I want to add business days using the GlideSchedule API. Here is the code:

var startDate = new GlideDateTime(current.sys_created_on);
var days = 5;
var schedule = new GlideSchedule("08fcd0830a0a0b2600079f56b1adb9ae"); // 8-5 weekdays excluding holidays
var duration = new GlideDuration(1000 * 60 * 60 * 9 * days);
var end = schedule.add(startDate, duration);

 

The code is working fine, but the issue is that if the start Date is on December 20, it adds 5 days and ignores December 25, which is a holiday. If I select December 19, it adds 5 days and ignores December 24, resulting in December 25, which is incorrect since it is also a holiday.

How can I ensure that both holidays are ignored, so that the calculation correctly considers all holidays?

Thanks in Advance
1 REPLY 1

aizawaken
Tera Guru

hi @kummara _siva ,


var schedule = new GlideSchedule("08fcd0830a0a0b2600079f56b1adb9ae"); // 8-5 weekdays excluding holidays
Is this sys_id ("08fcd0830a0a0b2600079f56b1adb9ae") correct?


It seems that this sys_id is for "8-5 weekdays", and sys_id : "090eecae0a0a0b260077e1dfa71da828" is for "8-5 weekdays excluding holidays".
Could you check this point in your end?