Is it possible to set the subject of an email client template using an email script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 08:02 AM
I have created a custom email client template in my pdi which uses the London version.
I would like the subject to be set using an email script.
I am able to set the content of the email client template using the following for example:
template.print('hello world');
However, if I try to set the subject of the email client template using the following code in an email script:
email.setSubject('hello world');
This does not set the subject.
I have checked the system log, the email seems to be returning a value of null (please see attached screengrab).
Does anyone have any suggestions of how I would be able to set the subject using an email script? Or is there a known error that anyone is aware of? It is not an option for me to use the subject field provided in the email client template.
Thanks,
Sue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 08:04 AM
You would have to use a mail script to do it, with email.setSubject, unfortunately.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 08:05 AM
Thanks, yes I am using a mail script, however this will not set the subject.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 08:14 AM
Hey Sue,
You are using the correct code: email.setSubject("Hello World");
Sometimes the subject won't be set until the email is sent or there may be another issue in your script. I would try making a separate one and trying it.
There may also be an issue with it, but I was able to get it work. The other thing you can do is make a field and call that in the subject and build it through that.
Also, the setSubject should not return a value. https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=c_GlideEmailOutboundScopedAPI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2019 11:44 PM
Thanks for your help.
I'll give it another try and see how I get on.