Email Script - trimming leading blank character | Adobe Higher Education
Skip to main content
April 5, 2016
Risolto

Email Script - trimming leading blank character

  • April 5, 2016
  • 3 risposte
  • 2414 visualizzazioni

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

Questo argomento è stato chiuso alle risposte.
Migliore risposta di

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.

3 risposte

April 5, 2016

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

April 5, 2016

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

April 6, 2016

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.

April 6, 2016

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

April 6, 2016

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

April 6, 2016

That would be cool!

Risposta
April 8, 2016

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.

April 9, 2016

Thanks Jason.

Rajesh