Execute JS in subject variable | Community
Skip to main content
December 4, 2017
Solved

Execute JS in subject variable

  • December 4, 2017
  • 3 replies
  • 2503 views

Hello,

In a delivery template, in the text version, we use this code to retrieve the subject dynamically:

<% document.write(delivery.mailParameters.subject); %>

The problem is that if there is javascript inside the subject, it is not executed.

For instance, if the subject is : <%=recipient.firstName%>, how are you doing?

It won't execute the firstname variable and will display the all thing as plain text.

Is there any means for avoing this issue?

Thank you very much for your help!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ramakatt

Hi,

This is working for me both in subject line and body of the email. Please find the process screens below and post your screenshots, if you are still facing this problem

s_ncs_user_wizard_email_object.png

s_ncs_user_wizard_email01_139.png

s_ncs_user_wizard_email01_140.png

Thanks,

Rajesh

3 replies

florentlb
Level 10
December 8, 2017

Hi,

I'm not sure that what's in the text version of an email can be interpreted other than as plain text.

If you find a solution, please post it here for reference. I'll try to ask around in the meantime.

Florent

ramakattAdobe EmployeeAccepted solution
Adobe Employee
December 11, 2017

Hi,

This is working for me both in subject line and body of the email. Please find the process screens below and post your screenshots, if you are still facing this problem

s_ncs_user_wizard_email_object.png

s_ncs_user_wizard_email01_139.png

s_ncs_user_wizard_email01_140.png

Thanks,

Rajesh

christophec3473
Level 2
December 15, 2017

Hi,

If you use a typologie rule which consider the content of your delivery text content, you will able to add your script in this content.

//script in your rule

var txtStr = delivery.content.text.source;

delivery.content.text.source = '<% document.write(delivery.mailParameters.subject); %>' + txtStr;

Return true;

I don't know if your Javascript don't work in the text context but, it's ok in the html context.

This answer can help you ?

Christophe