Skip to main content
Level 3
Jun 19, 2020 1:18 PM UTC
Solved

Include option value in string

Hello,

 

In a delivery template, is it possible to get the value of an option without using an include (<%@ include option='myOption' %>)?

I actually need to include an option in a javasript string :

 

<%

var string = "Hello, blabla: [option]";

%>

 

Thank you 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.
isahore
isahoreAccepted solution
Community Advisor
Jun 20, 2020 7:13 PM UTC

Hi @roro_coeur,

 

You cannot use option variables inside your delivery as the MTA does not get the options from your marketing instance, and also does not support the GetOption() method.

You will need to read the option variable in a js activitiy prior to the delivery, or in the initialisation script of your delivery activity as something like this:

var.thisOption = getOption("readMyValue"); //readMyValue is an example option variable name

 

Then use it in your delivery activity as you want it: <%= vars.thisOption %>

 

Thanks,

Ishan

5 replies

Jonathon_wodnicki
Community Advisor
Community Advisor
Jun 20, 2020 5:23 AM UTC

Hi,

 

<% var string = "Hello, blabla: " + getOption('[option]'); %>

 

Thanks,

-Jon

Translate
Level 3
Jun 20, 2020 9:22 AM UTC
Hello Jon, from what I know getOption works in iavascript templates not delivery template (except in preview mode).
Translate
isahore
Community Advisor
isahoreCommunity AdvisorAccepted solution
Community Advisor
Jun 20, 2020 7:13 PM UTC

Hi @roro_coeur,

 

You cannot use option variables inside your delivery as the MTA does not get the options from your marketing instance, and also does not support the GetOption() method.

You will need to read the option variable in a js activitiy prior to the delivery, or in the initialisation script of your delivery activity as something like this:

var.thisOption = getOption("readMyValue"); //readMyValue is an example option variable name

 

Then use it in your delivery activity as you want it: <%= vars.thisOption %>

 

Thanks,

Ishan

Translate
Level 3
Jun 30, 2020 12:11 PM UTC
Thank you very much! It makes sense!
Translate