- 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-18-2020 11:46 AM
Hi Sandy,
Try using below in subject with same format for Scheduled Reports.
javascript: 'Your Text here '+gs.nowDateTime().split(' ')[0]
For normal notifications
You need to create a mailscript from System Notificaiton >> Email >> Notification Email Script named getdatetimevalue with below code.
var dateis = gs.nowDateTime().split(' ')[1];
email.setSubject("your text for report"+dateis);
& then call it in your notification body as below
${mail_script:getdatetimevalue}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 12:24 PM
Thanks - this is close but for some reason it's only giving the time.. not the date. Any ideas?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 12:40 PM
Try using below & confirm (should give you date & time). Also, can you kindly confirm the DateTime format you use.
var dateis = gs.nowDateTime();
email.setSubject("your text for report"+dateis);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 07:43 AM
Did the above worked?