Marketo Token using SFDC custom object - test email ok but not batch email

Highlighted
Level 1

Marketo Token using SFDC custom object - test email ok but not batch email

Hi, 

We are developing some post-purchase confirmation emails after students enroll in a course.

I have created tokens and they work on the preview and test, but nothing is displayed when the email is sent on a batch- smart campaign

.

Could you please help?

 

Token:

#set($listSize = $Course_Enrollment__cList.size() - 1)

$!Course_Enrollment__cList.get($listSize).Course_Offering_Product_Name__c

 

Below is the filter used to send the email 

Maria_Riley1_0-1586128869787.png

Thanks

 

7 REPLIES 7
Highlighted
Level 10 - Community Moderator

Re: Marketo Token using SFDC custom object - test email ok but not batch email

Please highlight any posted code so it's readable. Then we'll continue.

 

syntax_vtl.png

Highlighted
Level 1

Re: Marketo Token using SFDC custom object - test email ok but not batch email

Thanks, 

changes made, 

cheers, 

Maria

Highlighted
Level 10 - Community Moderator

Re: Marketo Token using SFDC custom object - test email ok but not batch email

To start with, your naming convention is off. The size() of a List is... the actual size.  If you want to reference the last index then your variable should reflect that.

 

You should also be using the $math.sub method, since the subtraction - operator is not actually supported (it only works in your case because the parser sometimes lets it through; it will not work if you use $a-$b without a space, for example).

 

So a more semantic & less fragile version of your code is:

 

#set( $lastIndex = $math.sub($Course_Enrollment__cList.size(),1) )
#set( $lastCourse = $Course_Enrollment__cList.get($lastIndex) )
$!lastCourse.Course_Offering_Product_Name__c

 

Now, to the question of output.  You should only be testing Velocity-powered emails using either [a] preview-by-list or [b] a real email, never a sample. The sample can have little to no resemblance to the real-life result. Similarly, you need to check in both Batch and Trigger campaigns (if you might use both to send the same email) as the results can and will differ!

To debug this further, you should begin by outputting the entire $Course_Enrollment__cList in an email. Prematurely suppressing a possibly-null property (with the $!) makes things much harder to track down.

 

 

Highlighted
Level 1

Re: Marketo Token using SFDC custom object - test email ok but not batch email

Hi Sanford,

Thanks for your feedback, 

I made the appropriate changes but the result is the same. The course name doesn't get displayed.

Anything you could think of that could help?

 

Highlighted
Level 10 - Community Moderator

Re: Marketo Token using SFDC custom object - test email ok but not batch email

Have you tested outputting the entire list as I suggested?

 

Are you using different tokens by some chance, and you haven't checked the CO off in the tree in Script Editor?

Highlighted
Level 1

Re: Marketo Token using SFDC custom object - test email ok but not batch email

Hi, it worked, thanks heaps!

your help was very much appreciated. I found that I had a smart campaign and email on different folders. Tokens were not on the smart campaign folder.

I have placed everything in the same folder and it works now. 

What are the best practices on tokens and campaign folders? can I have smart campaign and email on different folders as long as the parent folder has the tokens?

Highlighted
Level 10 - Community Moderator

Re: Marketo Token using SFDC custom object - test email ok but not batch email


can I have smart campaign and email on different folders as long as the parent folder has the tokens?


Yes, have the tokens as high up in the tree as you can. There's always the ability to override tokens - but you can't share tokens with sibling or parent levels.