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

Jogen
Kilo Guru

Can you use 'sys_created_on' instead of the label created.



--Jogen


Notification has defined on the user table


Please follow the thread it can be helpful.



Client Script Date/Time Functions



code:



var ajax = new GlideAjax('ClientDateTimeUtils');  


ajax.addParam('sysparm_name','getNowDateTime');  


ajax.getXML(doSomething);  


 


function doSomething(response){  


var answer = response.responseXML.documentElement.getAttribute("answer");  


alert(answer);


tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Naveen,



Running something similar to your code in Background scripts gives me the following output



var created = new GlideDateTime();    


gs.print("created "+ created);  


*** Script: created 2015-09-03 08:23:41


Timestamp is in GMT



Have you checked to see if adding ${mail_script:Test} to the Subject line works as you expect? Perhaps with a very simple script.



Best Regards



Tony