Skip to main content
selvandhanm3541
Level 2
Nov 18, 2019 11:52 AM UTC
Solved

Writing conditions based on personalization blocks

Hello there,

We have a requirement wherein we would like to choose the delivery subject based on the availability of value calculated by a personalization block for a recipient.

if ('%><%@ include view="<a_personalization_block>" %><%' != '') {

  <%@ include view="<a_personalization_block>" %>

} else {

...

}

Have tried the above code block, but it fails. Is it possible to expand a personalization block for a recipient via js code (rather than via scriptlet expressions)?

Are there any alternatives to achieve the above?

Thank you!

Cheers,

Selva

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Jonathon_wodnicki
Jonathon_wodnickiAccepted solution
Community Advisor
Nov 18, 2019 3:36 PM UTC

Hi,

Create 2 personalization blocks:

  1. Create a function for the conditional in one personalization block
  2. Write all your subject line personalization in the second, calling the first

Thanks,

-Jon

3 replies

Jonathon_wodnicki
Community Advisor
Jonathon_wodnickiCommunity AdvisorAccepted solution
Community Advisor
Nov 18, 2019 3:36 PM UTC

Hi,

Create 2 personalization blocks:

  1. Create a function for the conditional in one personalization block
  2. Write all your subject line personalization in the second, calling the first

Thanks,

-Jon

Translate
selvandhanm3541
Level 2
Nov 18, 2019 3:43 PM UTC

Thanks Jon, could you provide an example of calling personalization block 1 from block 2?

Cheers,

Selva

Translate
Aug 4, 2020 12:34 PM UTC

personalization blocks essentially work like an include statement and they will be imported before javascript part is executed. 

 

So define a variable inside your personalization block. something like that:

 

<% var myText = "..."; %>

 

then for your caption do a jssp check (make sure the view is included before that):

 

<%@ include view="myPersonalizationBlock"%><% if (undefined !== myText) { %>Conditional caption<% } %>

 

for your message body just print the message out

 

<%= myText %>

 

Note "undefined !== myText" can be replaced with any condition you need

 

 

 

Translate