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't have?

So this issue has been resolved. I just updated all {{system.date}} flow steps in entire instance with {{system.dateTime}} so the times will all match in the daily CRM-Marketo sync.

Yes. But you should also wrap the first set of conditions in a not-equals check

This image is the snapshot of the transition from Product 8 to the not-equals check.

pastedImage_1.png

Sorry but I really can't sign off on your implementation

I understand that and I will certainly test once I at least "think" I have the script correct. For example, if this image is correct I can move in that direction, however, I'm not certain you meant to script it the way I have here or if you meant something else.

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?

That's not valid VTL, it will throw a fatal error instantly as you'll see in Preview.

I'm saying you need to wrap the entire Calendar creation in an isEmpty() check. The #etc., etc. represents where you'd put your existing code. You're adding a precondition around it, also called a guard.

#if( !$lead.ProductXSubscribed.isEmpty() )
#set( $calProductXSubscribed = $convert.toCalendar(
$convert.parseDate(
$lead.ProductXSubscribed,
$ISO8601,
$defaultLocale,
$defaultTimeZone
)
) )
#if( $date.difference($calNow,$calProductXSubscribed).getHours() >= -24 )
You subscribed to Product X within the past 24 hours.
#end
#end‍‍‍‍‍‍‍‍‍‍‍‍‍
Highlighted
Level 4

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

Got it. I think. This now has the first set of conditions wrapped per product for an isEmpty() check. Then following the Calendar creation and guard I then transition into the #if( $lead.ProductXSubscribed.equals("") ) check to send that appropriate messaging.

This image transition from Product 8 into still yet to Subscribes.

pastedImage_2.png

I believe that is now accurate and correct. But in my email test sends I don't see anything populating. Where exactly do I place the {{my.VelocityTimeZone}} token?

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?

  • You can't send samples to test Velocity, you must send real emails
  • You don't need to send emails at all, using Preview-by-List with a static List (add a few representative leads) is the only way to stay sane while troubleshooting Velocity code
  • Please don't call this token {{my.VelocityTimeZone}}, it doesn't have anything do with the purpose/output; variables should have accurate + complete names, {{my.RecentlySubscribedProducts}} for example
  • You'd put the token in the body of an email, as with other {{my.tokens}} (or in theory in the Subject line, but presumably this content is designed for the body)
Highlighted
Level 4

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

I've done everything you suggested. The email Preview-by-List view does not populate the token. And just after I felt soooo close. Bummer. Is this an indication of the VTL being broken somewhere or what could be causing this?

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?

You'll have to add some debugging lines. If you just put

${display.list( $lead.entrySet(), "\u000a" )}

on a line by itself, that will show you what the lead object looks like in raw form. Go to the Text version of the email to look at the output, then you can post a screenshot.

Highlighted
Level 4

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

This was the result of that line.

pastedImage_1.png

Interestingly in a different email template I used for testing it rendered differently. And I should note this version is the actual template this emails will be built from.

pastedImage_1.png

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?

Do you have the required fields checked off in the tree on the right-hand side of Script Editor? Sure doesn't look like it.

Highlighted
Level 4

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

Nope. I had no clue. Sorry. Your level of frustration must be approaching record levels.

I checked all 8 Product Subscribed and all 8 Product Subscribed Date only. Is that correct?

Here is the result of that...

pastedImage_1.png

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?

That's better, but you said they were DateTimes... those are stringified Date fields.