- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 04:25 AM
I have two field "MI service restore(u_time_when_the_resolved_notif) and MI action due date(u_mi_action_due_date). I want to add 7 days to MI service restore and display in MI action due date.
I have written Business rule for this but it's not displaying the date.
Here is my code:
var gdt = new GlideDateTime(current.u_time_when_the_resolved_notif);
var aft= gdt.addDays(7);
gs.addInfoMessage("time after adding date: "+ aft);
current.u_mi_action_due_date = gdt.getDate();
current.update();
Can anyone help me on this.
Regards,
Sowmya
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 05:41 AM
ok then you have to do glide record here to update the column on incident task table.
eg:
var gdt = new GlideDateTime(current.u_time_when_the_resolved_notif);
gdt.addDaysLocalTime(7);
gs.addInfoMessage("time after adding date: "+ gdt.getDisplayValue());
var gr = new GlideRecord('incident_task');
gr.addQuery('incident',current.sys_id); // make sure the relationship field is parent or incident.
gr.query();
while(gr.next()){
gr.<your date field on incident task > = gdt.getDisplayValue();
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 04:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 04:41 AM
Hello Sowmya,
Try below code for adding days:
var gdt = new GlideDateTime();
gdt.addDaysLocalTime(30);
current.u_mi_action_due_date = gdt;
Note:addDays() is a deprecated method so try using addDaysLocalTime().
else try like this in Background script:
var nd = new GlideDateTime(gs.nowDateTime());
gs.print('current date is :'+nd);
var fd = new GlideDateTime(nd);
fd.addDays(30);
gs.print('future date will be:'+fd);
I hope this will help you.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response useful to you and help others to find information faster.
Thanks,
Tejas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 04:51 AM
Hi
I have tried like this but still it's not displaying the date.
below is the code:
var gdt = new GlideDateTime(current.u_time_when_the_resolved_notif);
var aft=gdt.addDaysLocalTime(30);
gs.addInfoMessage("time after adding date "+ aft);
current.u_mi_action_due_date = gdt;
Thanks,
Sowmya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 05:14 AM
Hi,
Try like this
var gdt = new GlideDateTime(current.u_time_when_the_resolved_notif);
gdt.addDaysLocalTime(30);
var aft=gdt.getDisplayValue();
gs.addInfoMessage("time after adding date "+ aft);
current.u_mi_action_due_date = aft;
Thanks,
Tejas