Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

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