- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 02:58 AM
I need to set due date in the problem task form based on 5 Business days from the created date.
If it's Saturday (6) or Sunday (7) I need to move the date to Monday. I mean I need to skip the weekends and count only the working days to set the due date.
@Ankur Bawiskar Could you please help me on this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 05:04 AM
Hi @karunasrikuna ,
go with a business rule with a below script :
var createdDate = new GlideDateTime(current.sys_created_on);
var dueDate = new GlideDateTime();
var businessDaysToAdd = 5;
while (businessDaysToAdd > 0) {
dueDate.addDays(1);
if (dueDate.getDayOfWeek() != 6 && dueDate.getDayOfWeek() != 0) {
businessDaysToAdd--;
}
}
if (dueDate.getDayOfWeek() == 6) {
dueDate.addDays(2); // Move to Monday
} else if (dueDate.getDayOfWeek() == 0) {
dueDate.addDays(1); // Move to Monday
}
current.due_date = dueDate;
current.update();
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 11:03 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 04:31 AM
There is more than likely a schedule [cmn_schedule] already in the system for you to use. You can then leverage the GldieSchedule API to add 5 business days, it'll auto-skip over non-business days based on the provided schedule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 05:04 AM
Hi @karunasrikuna ,
go with a business rule with a below script :
var createdDate = new GlideDateTime(current.sys_created_on);
var dueDate = new GlideDateTime();
var businessDaysToAdd = 5;
while (businessDaysToAdd > 0) {
dueDate.addDays(1);
if (dueDate.getDayOfWeek() != 6 && dueDate.getDayOfWeek() != 0) {
businessDaysToAdd--;
}
}
if (dueDate.getDayOfWeek() == 6) {
dueDate.addDays(2); // Move to Monday
} else if (dueDate.getDayOfWeek() == 0) {
dueDate.addDays(1); // Move to Monday
}
current.due_date = dueDate;
current.update();
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 10:22 PM
I have used this BR , but now i am facing this issue. Can you please help me on this. Attaching the screenshots. Can you please help me ASAP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 10:29 PM