- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 11:30 AM
I have an email notification that calls several mail scripts.
I am looking to add the current date to the subject of the email -- so "Notification for - Current Date"
It seems like there should be a way to do this but I can't figure it out. Has anyone done this?
Thanks,
Sandy
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 12:35 PM
Can you try below then,
(function runMailScript(current, template, email, email_action, event) {
var gDateTime=new GlideDateTime();
var gDate = new GlideDateTime().getDate();
var gFormat=gDate.getByFormat('EEEE, MMMM dd');
var gt = (new GlideDateTime()).getLocalTime().getByFormat('hh:mm a');
//gs.print(gt);
//var TFormat=gt.getByFormat('HH:mm');
var FinalFormat=gFormat+' '+gt;
//gs.print(FinalFormat);
template.print(FinalFormat);
})(current, template, email, email_action, event);
Output as desired.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 08:50 AM
Hi - this is what I used to get it to work - template.print(gs.nowDateTime());
However, now I am trying to change the format to be Tuesday, May 18... the code above returns "2020-05-18" and it also includes the time.. do you have any idea if I am able to convert the time format?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 11:02 AM
Hi Sandy,
Try using below.
(function runMailScript(current, template, email, email_action, event) {
var gDTis = gs.nowDateTime();
var gDT = new GlideDateTime(gDTis);
var gDate = gDT.getDate();
var gDTFormat = gDate.getByFormat("MMMMMMMM d");
var gDayis = gDT.getDayOfWeekLocalTime();
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var n = weekday[gDT.getDayOfWeekLocalTime()];
var finalis = n + ',' + gDTFormat;
template.print(finalis);
})(current, template, email, email_action, event);
Output as below,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 11:14 AM
That's great! Now I am just trying to figure out how to get the time in there - the customer is asking for the current time to be added - Tuesday May 19, 2:14PM... would you be able to help me one last time 🙂 Thank you so much!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 11:53 AM
Hi Sandy,
Find below the simplified version.
(function runMailScript(current, template, email, email_action, event) {
var gDate = new GlideDateTime().getDate();
var gFormat=gDate.getByFormat('EEEE, MMMM dd');
var gt = gDate.getLocalTime();
var TFormat=gt.getByFormat('HH:mm');
var FinalFormat=gFormat+' '+TFormat;
template.print(FinalFormat);
//email.setSubject("your text for report " + FinalFormat);
})(current, template, email, email_action, event);
Output:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 11:58 AM
THat is perfect! thank you so much for your help!!!!