This email script I created works perfectly with one exception. It returns with a leading blank character. Not sure why it does this but I imagine there is a way to trim.
##check if the Preferred Name is populated and set
#if(${lead.Prefered_First_Name__c} != "")
#set($birthdayfirstname = "${lead.Prefered_First_Name__c}")
##check if the First Name is populated and set
#elseif(${lead.FirstName} != "")
#set($birthdayfirstname = "${lead.FirstName}")
#else
#set($birthdayfirstname = "default")
#end
##print the image name
${birthdayfirstname}
Boom shakalaka
Solved! Go to Solution.
Thanks for your help Rajesh. Real knowledgeable resource in case others are looking for help with email scripting or webhooks. Here is the final code.
##check if the Preferred Name is populated and set
#if(${lead.Prefered_First_Name__c} != "")
#set($birthdayfirstname = "${lead.Prefered_First_Name__c}")
##If Preferred Name is blank check if the First Name is populated and set
#elseif(${lead.FirstName} != "")
#set($birthdayfirstname = "${lead.FirstName}")
##If Preferred name and First Name is blank set default
#else
#set($birthdayfirstname = "default")
#end
##print the image name
${birthdayfirstname}
***When working with email scripting makes sure to eliminate white space within your formatting.
May be there is a blank space before ${birthdayfirstname} in your script.
DId you try putting delimiters like >>${birthdayfirstname}<< in the script to see if the leading blank is indeed in the ${birthdayfirstname} variable value?
Did you try $birthdayfirstname
You can indeed use trim function if that value have a leading blank.
$birthdayfirstname.trim()
Rajesh
Yes I used delimiters that's how I know there is a pesky leding blank character. I will try trimming and report back. Thanks!
I believe the issue is I'm outputting the token as part of a url string to the image location. This is the only instance I'm seeing a leading blank character. I'm going to try and pass the whole url in the token and see if that works.
I spoke to soon. The leading blank character is in any format I output. I will trying trimming next.
Here is the result
https://s3.amazonaws.com/anx-email/birthday/ xxxxJasonxxxxx.jpg
SCRIPT
##check if the Preferred Name is populated and set
#if(${lead.Prefered_First_Name__c} != "")
#set($birthdayfirstname.trim() = "${lead.Prefered_First_Name__c}")
##check if the First Name is populated and set
#elseif(${lead.FirstName} != "")
#set($birthdayfirstname.trim() = "${lead.FirstName}")
#else
#set($birthdayfirstname.trim() = "default")
#end
##print the image name
xxxx${birthdayfirstname}xxxxx
Hi Jason,
If it helps, we can do a join.me session and see if we can jointly solve this one.
Trying to add value to the community...
Rajesh
That would be cool!
Did you get my invite?