SOLVED

Email Script - What am I doing wrong?

Go to solution
Taylor_McCarty
Level 4

Email Script - What am I doing wrong?

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

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Script - What am I doing wrong?

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

 

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Script - What am I doing wrong?

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 4

Re: Email Script - What am I doing wrong?

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 - Community Moderator

Re: Email Script - What am I doing wrong?

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).

Taylor_McCarty
Level 4

Re: Email Script - What am I doing wrong?

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.

SanfordWhiteman
Level 10 - Community Moderator

Re: Email Script - What am I doing wrong?

Correct, the Opportunity fields are truly nullable.