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.

Add info to subject with Email Script in Email Client Template (email action on a Change record)

Dorian MOREL
Tera Contributor

Hello there,

 

I am trying to run an email script to add the current month to the subject, but it won't work.

 

DorianMOREL_0-1764341225408.png

Any idea why ?
I'm calling my email script in the HTML field of the Email Client Template. It should be running when a user wants to send an Email with the email feature on a Change record.

 

If it is impossible with this method, is there any workaround to achieve what I want to do ? 

 

Thank you in advance.
Dorian

 

2 REPLIES 2

Anand2799
Tera Guru

Hi @Dorian MOREL ,

 

Try this:

    var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

    var gdt = new GlideDateTime(); //November
    var current_month = gdt.getMonth(); // returns number

    email
.setSubject("Test Subject : " + months[current_month - 1]);


Thanks

Anand

Sarthak Kashyap
Mega Sage

Hi @Dorian MOREL ,

 

Can you use it in your notification subject, as shown in below image

 

SarthakKashyap_0-1764343387633.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,
Sarthak