how to calculate RITM due_date for "8-5 weekdays" schedule ?

bala_1312
Tera Contributor

how to calculate RITM due_date for "8-5 weekdays" schedule ?

2 REPLIES 2

Rajesh Chopade1
Mega Sage

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;

Vijay kumar S1
Tera Expert

Hi Debo,

 

Please follow below steps for calculating 

 

  1. 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.

  2. 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.

  3. In the "Due Date" field, set the "Schedule" field to the business calendar you created in step 1.

  4. Set the "Start Date" field to the date when the RITM was created.

  5. 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