Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Set template to a Delivery Activity using a JavaScript code activity

Avatar

Level 5

Hi, I would like to know if there is a way to set one delivery activity template using JavaScript code by sending the Delivery template internal name or label. 

 

Case of use example: 

 

"I've a list of Recipients with different languages. I loop at them and, for every one, I use an If to select one template name or another. After it, I send it to the delivery activity to have one kind of email or another. "

 

Also, is there any better way to do this?

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @CampaignerForLife 

 

The best solution would be to split the audience into different segments depending on the language and then use separate delivery for each segment.

 

Something like this:

Manoj_Kumar__0-1679484282167.png

 

If you want to use a single delivery then you can split the audience into different segments and give them a unique segment code. In the delivery use multiple if-else conditions to change the content on the basis of segment code.

 

In this case, the WF will look like this:

Manoj_Kumar__1-1679484460630.png

 

The dynamic condition code would look like this:

<% if(targetData.@segmentCode=='LANG1') { %>
Personalization block or content for LANG 1
<% } else if if(targetData.@segmentCode=='LANG2') { %>
Personalization block or content for LANG 2
<% } else if if(targetData.@segmentCode=='LANG\3') { %>
Personalization block or content for LANG 3
<% } else if if(targetData.@segmentCode=='LANG4') { %>
Personalization block or content for LANG 4
%> } else{ %> 
Fallback content
<% } %>

 

 

 


     Manoj
     Find me on LinkedIn

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Hello @CampaignerForLife 

 

The best solution would be to split the audience into different segments depending on the language and then use separate delivery for each segment.

 

Something like this:

Manoj_Kumar__0-1679484282167.png

 

If you want to use a single delivery then you can split the audience into different segments and give them a unique segment code. In the delivery use multiple if-else conditions to change the content on the basis of segment code.

 

In this case, the WF will look like this:

Manoj_Kumar__1-1679484460630.png

 

The dynamic condition code would look like this:

<% if(targetData.@segmentCode=='LANG1') { %>
Personalization block or content for LANG 1
<% } else if if(targetData.@segmentCode=='LANG2') { %>
Personalization block or content for LANG 2
<% } else if if(targetData.@segmentCode=='LANG\3') { %>
Personalization block or content for LANG 3
<% } else if if(targetData.@segmentCode=='LANG4') { %>
Personalization block or content for LANG 4
%> } else{ %> 
Fallback content
<% } %>

 

 

 


     Manoj
     Find me on LinkedIn

Avatar

Level 5

Thanks for your answer. Is there any way to set the  Template (And other activities config) using JS code) 

Avatar

Community Advisor

Hello @CampaignerForLife 

 

If you are using the start delivery from the actions tab.

Then you can use the script tab to dynamically select the template id.

example code:

delivery.scenario-cs=TEMPLATE_ID;
delivery.scenario-id=TEMPLATE_ID
delivery.save();

 

 


     Manoj
     Find me on LinkedIn

Avatar

Administrator

Hi @CampaignerForLife,

Could you share more details about what error are you getting, for @Manoj_Kumar_ to help you better?

Thanks!



Sukrity Wadhwa