- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 04:26 AM
Hi All,
I have to auto populate a date time field(due date) in problem Task form when the short description is "RCA" .The date should be current day + 10 Business days.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 08:23 AM
okay. what i understand is you want to set the short description and due date both when you are going to create a PR, in that case after Insert BR should help, please check if this helps.
(function executeRule(current, previous /*null when async*/) {
// Add your code herevar gdt = new GlideDateTime();
var gdt = new GlideDateTime();
if(gdt.getDayOfWeekLocalTime() == 6)
gdt.addDaysLocalTime(13);
else if(gdt.getDayOfWeekLocalTime() == 7)
gdt.addDaysLocalTime(12);
else //else add 14 days
gdt.addDaysLocalTime(14);
current.due_date = gdt.getDisplayValue();
current.short_description = 'Root Cause Analysis';
})(current, previous);
with the condition given like when the priority is high in condition builder:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 08:10 AM
Hi,
Create before insert business rule and add below script:
if(current.short_description.indexOf('RCA')>-1){
var sd = new GlideDateTime(gs.nowDateTime());
sd.addDays(5)
current.due_date=sd;
}
Thanks
Please Hit ✅Correct, ⭐️Helpful depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 08:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 03:36 AM
Hi Upender,
Thanks for the code,But I have to add 10 Business days with the current day, which exclude Saturday and Sunday.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 06:28 AM
you can try with this logic,
var gdt = new GlideDateTime();
if(gdt.getDayOfWeekLocalTime() == 6) //if it's Saturday let's add 13 days
gdt.addDaysLocalTime(13);
else if(gdt.getDayOfWeekLocalTime() == 7) //if it's Sunday let's add 14 days
gdt.addDaysLocalTime(12);
else //else add 14 days
gdt.addDaysLocalTime(14);
current.due_date=gdt.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 07:27 AM
Hi,
As Shishir replied:
10 Business Day includes saturday and sunday. So total days to be added 10+2=12
Now get today day if it is saturday then add 1 more days i.e. 12+1=13. If it is non saturday and sunday then add 2 more day.12+2=14. If it is sunday then add days 12.
Below is code
var gdt = new GlideDateTime();
if(gdt.getDayOfWeekLocalTime() == 6) //if it's Saturday let's add 13 days
gdt.addDaysLocalTime(13);
else if(gdt.getDayOfWeekLocalTime() == 7) //if it's Sunday let's add 14 days
gdt.addDaysLocalTime(12);
else //else add 14 days
gdt.addDaysLocalTime(14);
current.due_date=gdt.getDisplayValue();
Thanks
Hi,
Create before insert business rule and add below script:
if(current.short_description.indexOf('RCA')>-1){
var sd = new GlideDateTime(gs.nowDateTime());
sd.addDays(10)
current.due_date=sd;
}
Thanks
Please Hit ✅Correct, ⭐️Helpful depending on the impact of the response