Current Date in Email Notification

Sandy7
Tera Expert

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

1 ACCEPTED SOLUTION

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.

find_real_file.png

View solution in original post

18 REPLIES 18

Is it working the way it should or still any issues.

 

Also, if above comments helped you can mark it Helpful.

Hi Jaspal, It is giving the time but can you help such that the time zone should be according to the user's time zone???.

Ajaykumar1
Tera Guru

Hi Sandy,

Try this in your email script

 

var gdt = new GlideDateTime();
email.setSubject("Notification For - "+gdt.getDate());

 

Regards,
Ajay

Thank you!! this gives the date - sorry to ask but is there a way to also add the time to this?

I just want the Hour and Minute, not seconds.

Thanks again!