SOLVED

Re: Email Script - trimming leading blank character

Go to solution
Anonymous
Not applicable

Email Script - trimming leading blank character

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

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Email Script - trimming leading blank character

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.

View solution in original post

11 REPLIES 11
Anonymous
Not applicable

Re: Email Script - trimming leading blank character

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

Anonymous
Not applicable

Re: Email Script - trimming leading blank character

Yes I used delimiters that's how I know there is a pesky leding blank character. I will try trimming and report back. Thanks!

Anonymous
Not applicable

Re: Email Script - trimming leading blank character

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.

Anonymous
Not applicable

Re: Email Script - trimming leading blank character

I spoke to soon. The leading blank character is in any format I output. I will trying trimming next.

Anonymous
Not applicable

Re: Email Script - trimming leading blank character

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

Anonymous
Not applicable

Re: Email Script - trimming leading blank character

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

Anonymous
Not applicable

Re: Email Script - trimming leading blank character

That would be cool!

Anonymous
Not applicable

Re: Email Script - trimming leading blank character

Sure, Jason.

Please send email to Rajesh@BrightAspects.com

and we can take it from there.

Rajesh

Anonymous
Not applicable

Re: Email Script - trimming leading blank character

Did you get my invite?