Email Script not working on Subject line but working in body.

Gopi46
Kilo Contributor

Hi Team,

I have a requirement to populate one of the catalog variable as "Email Subject". I wrote a email script and trying to embed the script on Subject line but its not working. 

Please check the screenshots and appreciate any help.

Same script working on body section, but subject the same script not working. 

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

I don't believe mail scripts work in the subject line. The message body is where it gets executed from...and you can set the subject with the script: 

email.setSubject("This is the new subject line");

https://docs.servicenow.com/bundle/sandiego-servicenow-platform/page/script/server-scripting/referen...

You can also use just this in your subject:

This is my subject and here is a variable: ${current.variables.variable_name}

Please mark reply as Helpful/Correct, if applicable. Thanks!


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

View solution in original post

3 REPLIES 3

bammar
Kilo Sage
Kilo Sage

I think you can put mail scripts that have to do with subject into the body of the notification and they will work as long as the mail script setup right. 

Allen Andreas
Administrator
Administrator

Hi,

I don't believe mail scripts work in the subject line. The message body is where it gets executed from...and you can set the subject with the script: 

email.setSubject("This is the new subject line");

https://docs.servicenow.com/bundle/sandiego-servicenow-platform/page/script/server-scripting/referen...

You can also use just this in your subject:

This is my subject and here is a variable: ${current.variables.variable_name}

Please mark reply as Helpful/Correct, if applicable. Thanks!


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

thanks for the help.