- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2020 10:57 PM
Hi All,
I am sending a notification to the approver once the request is submitted. Body of the notification will be
Kindly approve the request which created on "Date 1" by "Abel Tuter". You have to approve/decline the request before "Date 1 +30".
I have written a mail script to print the date1, how can i add 30 days and display the date2 in notification.
Please find the email script below for date1 :
var request = new GlideRecord('sc_req_item');
request.get(event.parm1); //parm1 sys_id of ritm
template.print(request.opened_at);
I just tried the above in background script by addDays(30), am getting undefined. What mistake i am doing here.?
Output of BG
Regards,
Sirraj
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2020 11:06 PM
hello ,
Try below code for adding days:
var gdt = new GlideDateTime();
gdt.addDaysLocalTime(30);
current.datefield = 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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2020 11:47 PM
yes you can use in mail script. go with GlideSchedule method .
var startDate = new GlideDateTime('start date');
var days = 10;
var dur = new GlideDuration(60 * 60 * 24 * 1000 * days); // your duration goes here
var schedule = new GlideSchedule('sys_id of your weekday schedule');
var end = schedule.add(startDate, dur);
if my answer helped you, kindly mark it as correct and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2020 11:37 PM