Re: Velocity tokens conditonal scripting logic to display content based on having product subscription

Agoodwin
Level 1

Velocity tokens conditonal scripting logic to display content based on having product subscription

I'm creating a series of tokens so we can start using one email asset for several products. The token I am having trouble with is setting up several content blocks and displaying one if a lead has an active subscription to a qualifying product. It's approved when I place it inside the email, but when "previewing by list or person" nothing is being output. Here is the code I'm currently using in my token: 

 

#if( $zuoraSubscription.status == "Active" )

  #if( $zuoraSubscription.productName == "SOH" )
   block of content for SOH here.
  #elseif( $zuoraSubscription.productName == "WCA" )
  block of content for WCA here.
  #elseif( $zuoraSubscription.productName == "TPE" )
  block of content for TPE here.
#end
#elseif( $zuoraSubscription.isEmpty() )
You have no active subscriptions.
#end

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity tokens conditonal scripting logic to display content based on having product subscription

Not really enough info here, but at a fundamental level you shouldn't be using the == operator but rather .equals().

#if( $zuoraSubscription.status.equals("Active") )
#if( $zuoraSubscription.productName.equals("SOH") )
block of content for SOH here.
#elseif( $zuoraSubscription.productName.equals("WCA") )
block of content for WCA here.
#elseif( $zuoraSubscription.productName.equals("TPE") )
block of content for TPE here.
#end
#elseif( $zuoraSubscription.isEmpty() )
You have no active subscriptions.
#end

 

This condition

$zuoraSubscription.isEmpty()

doesn't make much sense, as the Map itself will never be empty in Marketo.

 

If you're not seeing any output at all, consider the cases that aren't covered by your conditions.