Does GlideSchedule() works?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2024 07:31 AM - edited ‎12-24-2024 07:32 AM
I am getting this error:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2024 08:05 AM
solution is present in this link. check that and enhance
Auto closure of Task after 3 business days
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2024 08:23 AM
Hello @Vasilis Anastas
The issue here is not with GlideSchedule() instead it is with schedule.duration.
To get the difference between two dates:
var duration = endDate.getNumericValue() - startDate.getNumericValue(); //return milliseconds
The script can be further updated as:
var g = new GlideRecord('incident');
g.addQuery('state', '6');
g.query();
while (g.next()) {
var days = 3;
var startDate = g.resolved_at;
var endDate = gs.now();
var schedule = new GlideSchedule();
schedule.load('c178fd23832ed61073c5b2b6feaad311'); // loads "8-5 weekdays excluding holidays" schedule
var duration = endDate.getNumericValue() - startDate.getNumericValue(); //return diff in milli seconds
if (duration >= days*86400000) { //one day is 86400000ms
g.state = '7'; // set as closed.
}
}
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar