SOLVED

How can I send 1 email with dynamic content blocks for products they have and products they don't have?

Go to solution
Highlighted
Level 4

Re: How can I send 1 email with dynamic content blocks for products they have and products they don'

There are a few different locations that may require the || in this scenario.

I will test but it's always easier to get as much info prior to really messing things up. πŸ™‚

In this first section below do I simply add the entire #if( !$lead.dMSTrialDateTime.isEmpty() ) content block duplicating the Subscribed block below or do I use the double pipe || and add the Trial content mirroring the Subscribed content for lines 1, 2 and 4 below?

 

#if( !$lead.dMSSubscribedDate.isEmpty() )
#set( $caldMSSubscribedDate = $convert.toCalendar(
 $convert.parseDate(
 $lead.dMSSubscribedDate, 
 $ISO8601WithSpace, 
 $defaultLocale, 
 $defaultTimeZone 
 )
) )

 

I do believe this portion is correct, right?

 

#if( $date.difference($calNow,$caldMSSubscribedDate).getHours() >= -24 ) || $date.difference($calNow,$caldMSTrialDateTime).getHours() >= -24 )

 

 

Highlighted
Level 4

Re: How can I send 1 email with dynamic content blocks for products they have and products they don'

@SanfordWhiteman 

I have tested this a few different ways but I can't seem to find the proper coding sequence to make it work.

Obviously utilizing only this will not work with the #if and #set VTL block for $lead.dMSSubscribedDate.isEmpty()  ) and !$lead.dMSTrialDateTime.isEmpty()  ) written.

#if( $date.difference($calNow,$caldMSSubscribedDate).getHours() >= -24 ) || $date.difference($calNow,$caldMSTrialDateTime).getHours() >= -24 )

I also tested using the entire $lead.dMSSubscribedDate.isEmpty()  ) and then followed that with the enitre !$lead.dMSTrialDateTime.isEmpty()  ) VTL block - which did not work.

Finally I attempted to combine them into a single block and edited using the || indicated below - which also does not work and returns the error shown in the image below.

Can you please correct my missteps?

 

#if( !$lead.dMSSubscribedDate.isEmpty() || !$lead.dMSTrialDateTime.isEmpty() )
#set( $caldMSSubscribedDate = $convert.toCalendar( || $caldMSTrialDateTime = $convert.toCalendar(
 $convert.parseDate(
 $lead.dMSSubscribedDate || $lead.dMSTrialDateTime, 
 $ISO8601WithSpace, 
 $defaultLocale, 
 $defaultTimeZone 
 )
) )

 

Highlighted
Level 10 - Community Moderator

Re: How can I send 1 email with dynamic content blocks for products they have and products they don'

The line

 

 

#if( $date.difference($calNow,$caldMSSubscribedDate).getHours() >= -24 ) || $date.difference($calNow,$caldMSTrialDateTime).getHours() >= -24 )

 

 

is a syntax error because you have mismatched parentheses. The correct parens are

 

 

#if( $date.difference($calNow,$caldMSSubscribedDate).getHours() >= -24 || $date.difference($calNow,$caldMSTrialDateTime).getHours() >= -24 )

 

 

 


Finally I attempted to combine them into a single block and edited using the || indicated below


This syntax does not work in Velocity, it might  be a valid JavaScript null coalescing sequence but it’s broken VTL:

 

 

$some.function( $param2 || $param2 )

 

 

 

I have no idea what you were expecting this use of || to do, it’s broken too:

 

 

#set( $caldMSSubscribedDate = $convert.toCalendar( || $caldMSTrialDateTime

 

 

 

Also, there’s no image inserted in your post.

Highlighted
Level 4

Re: How can I send 1 email with dynamic content blocks for products they have and products they don'

@SanfordWhiteman  can you help me solve this?

 

I have no idea what you were expecting this use of || to do, it’s broken too:

 

I'm just trying to figure out where the "any" or "or" (| |) belongs so I simply mirrored and added all "Trial" syntax on the lines where the "Subscribed" syntax was present. What I was expecting was the fact I know this works individually and I know this works in this fashion in the (&&) syntax I hoped by simply adding the |  | would result in the same output. I was wrong. That's why I'm here. I'm trying. At least by trying I am discovering what does not work.

 

 

 

Individually I know this is right for DMS Subscribed...

 

 

#set( $ISO8601WithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Los_Angeles") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601 = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#if( !$lead.dMSSubscribedDate.isEmpty() )
#set( $caldMSSubscribedDate = $convert.toCalendar(
 $convert.parseDate(
 $lead.dMSSubscribedDate, 
 $ISO8601WithSpace, 
 $defaultLocale, 
 $defaultTimeZone 
 )
) )
#if( $date.difference($calNow,$caldMSSubscribedDate).getHours() >= -24 )
You now have access to PRODUCT X!
#end
#end

 

 

And I know this is right for DMS Free Trial...

 

 

#set( $ISO8601WithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Los_Angeles") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601 = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#if( !$lead.dMSTrialDateTime.isEmpty() )
#set( $caldMSTrialDateTime = $convert.toCalendar(
 $convert.parseDate(
 $lead.dMSTrialDateTime, 
 $ISO8601WithSpace, 
 $defaultLocale, 
 $defaultTimeZone 
 )
) )
#if( $date.difference($calNow,$caldMSTrialDateTime).getHours() >= -24 )
You now have access to PRODUCT X!
#end
#end

 

 

What I wanted to do was utilize the "any" or "or" (| |) syntax so I added the "Trial" after the "Subscribed" and  | | .

 

This is what my vtl code looks like at the top - as you can see where my confusion lies in that the first #if references "subscribed" only. I would think I would have to include some code also scanning for "Trial" conditions. But where and how does that fit in?

 

 

#set( $ISO8601WithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Los_Angeles") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601 = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#if( !$lead.dMSSubscribedDate.isEmpty() )
#set( $caldMSSubscribedDate = $convert.toCalendar(
 $convert.parseDate(
 $lead.dMSSubscribedDate, 
 $ISO8601WithSpace, 
 $defaultLocale, 
 $defaultTimeZone 
 )
) )
#if( $date.difference($calNow,$caldMSSubscribedDate).getHours() >= -24 || $date.difference($calNow,$caldMSTrialDateTime).getHours() >= -24 )
You now have access to PRODUCT X!
#end
#end

 

 

 

Also, there’s no image inserted in your post.

ss-marketo.jpg

 

 

 

Highlighted
Level 4

Re: How can I send 1 email with dynamic content blocks for products they have and products they don'

@SanfordWhitemanJust wanted to follow up - I can take it to the community posed as a new post question if you prefer.

 

 Can you help me solve for combining the "Product X Trials" with the "Product X Subscriptions" using "any" or "or" conditions (utilizing the double pipe ||)?

 

Intellectually, I can see this is an easy function within velocity based on everything else I've done here as well as how seamless the use of the "and" (&&) function was to utilize.

 

The challenge is writing un-broken code. I assumed that in every line $lead.dMSSubscribedDate and $caldMSSubscribedDate appeared (the first #if and #set lines 9-17) would require the | | followed by the trial fields $lead.dMSTrialDateTime and $caldMSTrialDateTime.

 

I really appreciate and grateful for the help. Thank you.

Highlighted

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

Ronn Burner Thanks for this topic!   

Sanford Whitemanβ€Œ Is it possible to do the same with program membership instead of a boolean field? So: If Member Status = Registered in Program 1, then "welcome to session 1". If Member Status = Registered in Program 2, then "welcome to session 2". 

Highlighted
Level 10 - Community Moderator

Re: How can I send 1 email with dynamic content blocks for products they have and products they don't have?

Unfortunately no. Program membership is not a direct property of the lead.

If you used program membership to manage a segmentation, then the segment is a property of the lead (so could be used in personalization) but it's not updated in absolutely real-time.

Or have a field on the lead that's used as a mirror for their program status.