how to calculate RITM due_date for "8-5 weekdays" schedule ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2023 12:01 AM
how to calculate RITM due_date for "8-5 weekdays" schedule ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2023 12:13 AM
Hi @bala_1312
You can use bellow code
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
‎02-17-2023 12:30 AM
Hi Debo,
Please follow below steps for calculating
Create a business calendar that defines the "8-5 weekdays" schedule. To do this, go to "System Definition" -> "Calendars" -> "Business Schedules" and create a new calendar. In the calendar definition, set the working hours to 8:00 AM - 5:00 PM and select the weekdays you want to include.
In the RITM record, create a "Due Date" field and set it to use the "Calculate from schedule" option. This will allow you to calculate the due date based on the business calendar you created in step 1.
In the "Due Date" field, set the "Schedule" field to the business calendar you created in step 1.
Set the "Start Date" field to the date when the RITM was created.
Set the "Duration" field to the number of business days you want to allow for completion of the RITM. For example, if you want to allow 5 business days, set the "Duration" field to 5.
after completion of above steps you can get the required data.
Please mark correct or helpful if its helping
Thank you
Vijay