forked from ServiceNowDevProgram/code-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (19 loc) · 737 Bytes
/
script.js
File metadata and controls
26 lines (19 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var CaclculateDueDate = Class.create();
CaclculateDueDate.prototype = {
initialize: function() {},
calculateDueDate: function(date, days_to_add) {
var checkDate = new GlideDateTime(date);
var daysToAdd = days_to_add;
while (daysToAdd > 0) {
var sched = new GlideSchedule('c798c1dfc3907e1091ea5242b40131c8'); // Schedule record SYS_ID. Currently 9-5 Weekdays and Indian Public Holiday(excluded) schedule has been used
checkDate.addDaysLocalTime(1);
if (sched.isInSchedule(checkDate)) {
daysToAdd--;
} else {
continue;
}
}
return checkDate.getValue();
},
type: 'CaclculateDueDate'
};