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/b...) 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
Solved! Go to Solution.
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
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
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!
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).
So would that explain fields on the Opportunity object? Because I used similar logic on a script pulling in the Opportunity owners SMS number and it worked just fine. That is why I was so confused when the script for the Lead object didn't work.
Again thank you for replying and providing info, getting help like this from community members is one of the best things about Marketo in my opinion.
Correct, the Opportunity fields are truly nullable.