Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Include option value in string

roro_coeur
Level 3
Level 3

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,

1 Accepted Solution
isahore
Correct answer by
Level 3
Level 3

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

View solution in original post

5 Replies
wodnicki
Community Advisor
Community Advisor

Hi,

 

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

 

Thanks,

-Jon

roro_coeur
Level 3
Level 3
Hello Jon, from what I know getOption works in iavascript templates not delivery template (except in preview mode).
wodnicki
Community Advisor
Community Advisor
I just looked at the preview. You can always do getOption() in the activity's js and assign it to vars, then pick it up in the delivery using variables, as per usual for js.
isahore
Correct answer by
Level 3
Level 3

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

View solution in original post