Email Script - What am I doing wrong? | Community
Skip to main content
Taylor_McCarty
Level 3
September 16, 2020
Solved

Email Script - What am I doing wrong?

  • September 16, 2020
  • 1 reply
  • 3298 views

So I am trying to create a script that I though was going to be simple, but its not working and I have no clue why. I found this article (https://nation.marketo.com/t5/Marketo-Whisperer-Blogs/Basic-Email-Scripting-Examples-for-Marketers/ba-p/245747) and was trying a similar if then script. But when I run examples through, if the value is null for the SMS number, it doesn't display the "Default SMS Number" and instead still displays the Text: but without a number since the owner sms field is empty. 

 

 

 

#if(${lead.Owner_s_SMS_Number__c} == $null) Default SMS Number #else Text: <b><a href="tel:${lead.Owner_s_SMS_Number__c}">${lead.Owner_s_SMS_Number__c}</a></b> #end

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

First, bear in mind $null is just a convention (and not a broadly used one). It doesn't always represent the value null; it only represents null if you happen to remember to not use it for anything else!

 

But the problem here is you actually mean "empty or null", not null.

 

Which you check for with this construct:

#if( $display.alt($lead.Owner_s_SMS_Number__c,"").isEmpty() ) Default SMS Number #else Text: <b><a href="tel:${lead.Owner_s_SMS_Number__c}">${lead.Owner_s_SMS_Number__c}</a></b> #end

 

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
September 16, 2020

First, bear in mind $null is just a convention (and not a broadly used one). It doesn't always represent the value null; it only represents null if you happen to remember to not use it for anything else!

 

But the problem here is you actually mean "empty or null", not null.

 

Which you check for with this construct:

#if( $display.alt($lead.Owner_s_SMS_Number__c,"").isEmpty() ) Default SMS Number #else Text: <b><a href="tel:${lead.Owner_s_SMS_Number__c}">${lead.Owner_s_SMS_Number__c}</a></b> #end

 

Taylor_McCarty
Level 3
September 16, 2020

Would this be a result of that field in SFDC being a formula? So that is why the null wasn't working? 

 

Either way, thank you as always!

SanfordWhiteman
Level 10
September 17, 2020

Nope, it's because fields on the $lead object are always Strings, not nullable (this isn't the case with COs, where props are nullable).