How to create Dynamic Subject of email client Template?

Community Alums
Not applicable

I want to set the subject of my email client template:-

I created an email script and used:-

email.setSubject('');

and called the email script with tag ${mail_script:'name od email script'} in the body of the template.

But the value of the subject is not populating.

Please help!!!!!

19 REPLIES 19

Hi,

I just wanted to check in on this. If my reply above helped guide you correctly, please mark it as Helpful & Correct.

Thank you!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

So you have the date/time field and you only want the date from the field. If my understanding is correct then you can do that by using getDate() function. Please find the snipped below for reference:

find_real_file.png

Please refer to the below link for more details and functions of GlideDateTime:

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/c_GlideDateTimeAPI#r_G...

 

Also, I believe the invoke of email script was resolved with the previous reply from Sachin, Allen and me. Since, that's the only issue while invoking the email script in your syntax. It should be ${mail_script:name od email script} 

Kindly mark my answer as Correct and helpful based on the Impact.

Regards,

Alok

 

Ali Shaikh1
Giga Expert

Hi Adarsh Singh,

to set the subject of email client template:

 

${number} - ${short_description}

 

 

 

has to be a variable on the table

 

Mark as Helpful if solve your issue.

 

-Ali

Yaraslau
Tera Guru
(function runMailScript(current, template, email, email_action, event) {

  email.subject = 'My subject';         

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

works for me.

Jiri Hrdlicka1
Tera Contributor

Well, as email object is not supported within Email Client Templates - the only way, I was able to achieve expected result, was calculated variable on the table I was using for it. In my case - used for Major Incident Communication tasks, so my String variable was on [incident_alert_task] table. Worked well.