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?
#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
Please highlight any posted code so it's readable. Then we'll continue.
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.
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?
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?
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?
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.