Is it possible to set the subject of an email client template using an email script?

Sue22
Kilo Contributor

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

 

11 REPLIES 11

Chaddie
Tera Contributor

Marek Remi_
Tera Expert

Hello Sue, Everyone struggling with the subject field on Email Client Template.

 You cannot use email object when you call mail script from Email Client Template - 

 email: EmailOutbound object (null when called from Client Template)

There is a workaround how to insert anything into subject:

  1. Insert a unique string to a template subject, so we can filter by it later f.e. "IncidentCommunicationPlanEmailSubjectToReplace"
  2. Create before insert BR on sys_email table, condition - Subject is "IncidentCommunicationPlanEmailSubjectToReplace"
  3.  You can run any Script Include inside your Business rule to generate your subject
  4.  Then just do current.subject = .....

We were using it to create dynamic subject based on recipient's languages.

New subject will be generated before modal window used for sending mail pops-up so the sender will never see "IncidentCommunicationPlanEmailSubjectToReplace" subject.