Hi there,
We have leads that have a first name of [Not Provided], and we'd like to say if we identify the first name as such, fill in "there" as the value, if not identified as [Not Provided] use the value that lives in the field.
We have used as the token name:
{{my.First Name Script}}
{{lead.First Name:default=there}}
I have used the following tokens and I am still running into the issue;
#if ($lead.FirstName == "[Not Provided]")
there
#elseif ($lead.FirstName == "")
there
#else
$lead.FirstName
#end
**************************************************************************************************************
#if( $lead.FirstName.equals("[Not Defined]") || $lead.FirstName.isEmpty() )
there
#else
$lead.FirstName
#end
***************************************************************************************************************
#if( $lead.FirstName.equals("[Not Provided]") || $lead.FirstName.isEmpty() )there#else $lead.FirstName#end
**************************************************************************************************************
#if(${lead.First Name} == “[Not Provided]” || ${lead.FIrst Name} == “”)
$set($greeting = “Hi there,”)
#else
$set($greeting = “Hi ${lead.First Name},”)
#end${greeting}
Any insight on this would be greatly appreciated. I have tried all the above values and we are still getting a Hi [Not Provided].
Thank you!
Few things to confirm:
I just created a test record and used the code below which worked as expected to hide "[Not Provided]" from the greeting. Note, I prefer to use exclusionary logic vs. inclusionary logic for things like this (i.e. they have to qualify your rules to get the custom name, instead of the custom name being the default value).
Sanford is probably going to hate this code because it doesn't use the javascript markup, but in my personal opinion the simple markup works just fine for something like this.
##Confirm First Name is not provided or is blank
#if ($lead.FirstName != '[Not Provided]' && $lead.FirstName != "")
Hi $lead.FirstName,
#else
Hi there,
#end
Do you mean formal vs. simple references, Chris? I never use the term "JavaScript markup" (would be very confusing as Velocity has nothing to do with JS!).
Anyway, I don't hate it! ...
... but I don't like leaning on the type-juggling == and != operator. They'll appear to work, until they don't because of mismatched object types. In contrast, equals() and isEmpty() always work the same in any context, because they are typed. It's better to rely on those methods from the start, instead of getting bitten badly by an error and then switching to them.
It's also less confusing if null values don't match the first condition; even if you don't expect any nulls on the Lead object (only Strings) they're always possible on Custom Objects.
##Use First Name if not null, not blank, and not special placeholder string
#if( $lead.FirstName && !$lead.FirstName.isEmpty() && !$lead.FirstName.equals("[Not Provided]") )
Hi ${lead.FirstName},
#else
Hi there,
#end
Hah! I don't even know the lingo, yes formal vs. simple
This worked and was so helpful. Thank you!!