- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 07:37 AM
Hello Guys,
I am current developing a catalog item called EAI DPC request. In that there is a variable service needed which has 4 options as shown belwo
When the 1st option is selected, the due date on the RITM should be calculated to 8 business days. Right now I have written run script on workflow as below
\
if (current.variables.request_type == '1' && (current.variables.distributed_code == 'Yes' ||current.variables.services_mainframe_codes == 'Yes' )){
var gdt = current.due_date.getGlideObject();
gdt.addDays(4);
current.due_date = gdt;
}
The above code is working, but it is calculating concecutive days and not business days as show below:
as you can see, it is not calculating the business days.
Kindly share your views on how can I fix this issue.
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 06:12 AM
i got it guys, I used the below code and it is working.
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name', '8-5 weekdays');
if (typeof GlideSchedule != 'undefined')
var sched = new GlideSchedule(schedRec.sys_id);
else
var sched = new Packages.com.glide.schedules.Schedule(schedRec.sys_id);
//Get the current date/time in correct format for duration calculation
var currentDateTime = current.opened_at.getGlideObject();
//Set the amount of time to add (in seconds)
var timeToAdd = 8 * 32400;
durToAdd = new GlideDuration(timeToAdd*1000);
var newDateTime = sched.add(currentDateTime, durToAdd, '');
//Set the 'due_date' field to the new date/time
current.due_date = newDateTime;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 11:44 AM
Hi,
take a look here we I do pretty much the same thing. Got a date and in this example I want to have it 3 business days later, but I think you got the idea. Just ask if you there is something that you wonder about.
How to close ticket after 3 business days
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 06:12 AM
i got it guys, I used the below code and it is working.
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name', '8-5 weekdays');
if (typeof GlideSchedule != 'undefined')
var sched = new GlideSchedule(schedRec.sys_id);
else
var sched = new Packages.com.glide.schedules.Schedule(schedRec.sys_id);
//Get the current date/time in correct format for duration calculation
var currentDateTime = current.opened_at.getGlideObject();
//Set the amount of time to add (in seconds)
var timeToAdd = 8 * 32400;
durToAdd = new GlideDuration(timeToAdd*1000);
var newDateTime = sched.add(currentDateTime, durToAdd, '');
//Set the 'due_date' field to the new date/time
current.due_date = newDateTime;