Personalization variable in Delivery | Community
Skip to main content
Level 2
May 9, 2022
Solved

Personalization variable in Delivery

  • May 9, 2022
  • 1 reply
  • 2046 views

Hi, 

 

I want to have a personalized salutation in my emails. So it opens with something like:

Dear John

Dear Maria 

etc. 

 

Because of the way our setup is established i cannot use the target data extension for personalization. So i tried it with  javascript code and the delivery variables. But i'm stuck, because the salutation it picks is only the last one on the list. 

So i'm only getting:

Dear John

Dear John 

Dear John etc. 

 

My javascript skills are very basic so maybe i'm doing something wrong.

 

This is the code i use in the delivery:

var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);


var query = xtk.queryDef.create(

<queryDef schema={vars.targetSchema} operation="select">


<select>

<node expr="salutation"/>

</select>

</queryDef>

);


result = query.ExecuteQuery();

 

for each (var e in result) {

delivery.variables._var[0].stringValue = e.salutation

}

 

Thank you in advance 🙂 

 

Kind regards, 

 

 

 

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 CedricRey

Hi,

The targetData is only available when you start the delivery from a workflow.

Also you  won't see the option to use it with standard tools menu, but you will see it if you open the delivery from the workflow view (Open the targeting worflow, the "delivery" activity, the loop to open the delivery details and then you should be able to use the personalization menu to find 'Target Extension').

But as it can only be used with a workflow, it doesn't allow to preview the message (with the 'Preview' tab in the delivery form). It is a logical limitation, the only way to check your message is to send it (a proof or real message, as you want).

 

The simpliest way for your example to avoid the use of targetData, if the salutation is a field of your target schema (let's say nms:recipient ?), is to just write the following syntax :

<%= recipient.salutation %>

(or use the name of you schema if it's not recipient).

 

Cedric

1 reply

CedricRey
Level 5
May 10, 2022

Hi @j2021 , I think you mix up the delivery variables and the personalization variables.

What you are doing is to use let's say a "global" variable with "delivery.variables". It means that this object will be the same for every recipient of your delivery.

I suppose you don't want this.

You'll have to load this salutation in the custom personalization datas, because depending of the size of your target, you won't be able to load all the personalizations into a unique global variable.

 

I'm suprised why can't you use the target data extension ?

You mean that the code

<div><%=targetData.salutation%></div>

is not an option for you ?

 

Cedric

 

J2021Author
Level 2
May 10, 2022

Hi @cedricrey ,

 

Ah that makes a lot of sense. I couldn't find the setting behind the delivery variables so that's why i tried it this way. 

 

If i try to make use of the targetData variable it gives an error. And when i'm in the email itself i don't have the option to enrich it with targetData personalization as shown below. 

 

 

So that's why i went looking for another way to do the personalization. But i'm starting to wonder if there is another way to do it without the targetData. 

CedricRey
CedricReyAccepted solution
Level 5
May 10, 2022

Hi,

The targetData is only available when you start the delivery from a workflow.

Also you  won't see the option to use it with standard tools menu, but you will see it if you open the delivery from the workflow view (Open the targeting worflow, the "delivery" activity, the loop to open the delivery details and then you should be able to use the personalization menu to find 'Target Extension').

But as it can only be used with a workflow, it doesn't allow to preview the message (with the 'Preview' tab in the delivery form). It is a logical limitation, the only way to check your message is to send it (a proof or real message, as you want).

 

The simpliest way for your example to avoid the use of targetData, if the salutation is a field of your target schema (let's say nms:recipient ?), is to just write the following syntax :

<%= recipient.salutation %>

(or use the name of you schema if it's not recipient).

 

Cedric