- 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-23-2018 07:24 AM
Hi Shishir,
when a problem is created with Priority high it should create a problem task and the short description should be "Root Cause Analysis" and Due date should be current day + 10 Business days. So I wrote the client script OnLoad also I removed the condition when short description is "Root Cause Analysis" and tried your script even then it is not working.Please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 07:40 AM

- 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-23-2018 08:54 AM
Hi,
And write code in advance section
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 02:42 AM
After insert is working perfect 🙂 Thanks Upender