How to insert current year in Notification

AdamSaniS
Tera Contributor

Hi Experts!

 

Good day everyone. My team and I require advice on how to insert Current year (e.g.: 2026) in our email subject & content.

For example:

 

Subject: Annual Review 2026

Message:

Hi All, kindly review your RCSA for 2026

 

We have this email scheduled for every year but need expert's help on how to insert the current year in Subject and Message for email notification configuration in "What it will contain" section. Thank you so much for your kindness, time and support. 

 

Thanks and I really appreciate it!

1 ACCEPTED SOLUTION

@AdamSaniS 

you can include email script in your email body using this syntax

${mail_script:mailScriptName}

check this for further help

Notification Email Scripts 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @AdamSaniS 

 

https://www.servicenow.com/community/itsm-forum/email-script-needs-to-show-current-year/m-p/2513204

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@AdamSaniS 

you will have to use email script to set the subject with the current year etc

Don't set it via notification level.

Something like this

(function runMailScript(current, template, email, email_action, event) {

	// Add your code here
	var currentYear = new GlideDateTime().getYearUTC();
	var subject = 'Annual Review ' + currentYear;
	email.setSubject(subject);

})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

Many thanks for your response. I have tried to do email script before, but it failed to reflect when I put the script into my email message. How do I reflect the email script into my notification message? Thank you so much for your help - I feel so grateful

@AdamSaniS 

you can include email script in your email body using this syntax

${mail_script:mailScriptName}

check this for further help

Notification Email Scripts 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader