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

I have done that, but it is not working.


Subject does not supports the mail script i hope. Because i applied the same thing in the body, it does work.


Can you post your whole mail script from the email.


Perhaps something else is falling over.


Hi Daryll,



This is a simple mail script where i need to populate the current date in my notification subject.



Test


  1. var created = new GlideDateTime();    
  2. gs.log("created"+ created);  
  3.  
  4.  
  5. template.print(created);  

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



Message HTML:



Time card submission is late for ${name}.Time cards are due by 9 pm on Sunday, please submit your time card via this link


${mail_script:Test}






Once this notification runs, it is going to populate the   the below content.


Subject:


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




Body:




2015-09-03 09:17:57


Time card submission is late for Admin.Time cards are due by 9pm on Sunday, please submit your time card via this link.



I hope this helps.


The only thing I would question is "${mail_script:Test}" are you sure this is returning what you expect?