Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to populate the current date in email notification?

Naveen Kumar J
Tera Expert

Hi,

I am trying to populate the current date in the email notification by using an email script.

Here is my email script: Test

var created = new GlideDateTime();

gs.log("created"+ created);

template.print(created);

My notification subject is:

Your Time Card Submission is Late for the Reporting Period of ${mail_script:Test}

But this is not working.

Thanks,

Naveen

1 ACCEPTED SOLUTION
14 REPLIES 14

Yes, but only in the body. not in the subject


Hi!



Is there a way to modify your script to show the time in the system timzone for that user?


Thanks!


You can set dynamic subject through script using email object



http://wiki.servicenow.com/?title=Scripting_for_Email_Notifications#Overriding_Email_Fields


It is working   .



I have done this using email.setSubject.



var created = new GlideDateTime();


gs.print("created"+ created);




email.setSubject("Your Time Card Submission is Late for the reporting period of "+ created);


aksinghal
Kilo Contributor

Hi Naveen,



try this:



var nowdt = new Packages.com.glide.glideobject.GlideDateTime();


nowdt.setDisplayValue(gs.nowDateTime());



var cur_date = nowdt.getNumericValue();



cur_date will give you current date.