- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 10:29 PM
I need to calculate due date based on a schedule to assign SLAs to task.
This script shows my current date time as+4 hours in future .
var slaDays = 3;
var startDate = new GlideDateTime();
gs.info('ABC--startDate---' + startDate);
var days = parseInt(slaDays);
//assuming there are 9 business hours
days = days*9;
var dur = new GlideDuration(60 * 60 * 1000 * days);
var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); //8-5 weekdays excluding holidays
var end = schedule.add(startDate, dur);
gs.info('ABC--end---' + end);
//Output
*** Script: ABC--startDate---2022-04-12 05:29:34
*** Script: ABC--end---2022-04-15 15:00:00
//EXPECTING END DATE OUTPUT AS 04/15/2022 17:00:00
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 11:42 PM
Hi,
Have you tried using getDisplayValue() ?
var slaDays = 3;
var startDate = new GlideDateTime();
gs.info('ABC--startDate---' + startDate.getDisplayValue());
var days = parseInt(slaDays);
//assuming there are 9 business hours
days = days*9;
var dur = new GlideDuration(60 * 60 * 1000 * days);
var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); //8-5 weekdays excluding holidays
var end = schedule.add(startDate, dur);
gs.info('ABC--end---' + end.getDisplayValue());
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2022 03:56 AM
If you use timer then it will run on behalf of System. and will take system time.
Not sure why same is not working for admin, have you tried with timer with end user impersonation?
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2022 04:20 AM
I tried no impersonation with any other user.