- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2014 10:19 AM
Hi Andy,
Thanks for the scripting!! I created the '9 -5 weekdays' schedule and updated it in the scripting as you instructed me. The dueDays I left as 3 because I want it 3 business days from now and left the dueWorkingHours to 8. However, when I pull up the form after this has been entered it's populating the current date and time, instead of 3 business days from today - is there something else I forgot to change?
// Get the datetime now
var nowGdt = new GlideDateTime();
// The name of the schedule
var myScheduleName = '9 - 5 weekdays';
// The basis of our calculation
var dueDays = 3;
var dueWorkingHours = 8;
// The amount of time we want for the duration
var dueSeconds = dueDays*dueWorkingHours*60*60;
var leadTime = new GlideDuration(leadTimeSeconds*1000);
// Calculate the Due Date!
var dueDateGdt;
var schedRec = new GlideRecord('cmn_schedule');
if (schedRec.get('name', myScheduleName)) {
var sched = new GlideSchedule(schedRec.sys_id);
dueDateGdt = sched.add(nowGdt, leadTime, '');
}
gs.log('The Due Date is: '+dueDateGdt.getDisplayValue());