I'm trying to build a token using fields from a Marketo Custom Object. I want the token to print the field value if the field isn't empty, and to print nothing if the field is empty. When I run the code below it prints the full script of the token when the field value is empty:
#if( $sep2021TermsAndConditions_cList.get(0).policyName2.isEmpty() )
#else
<br />$sep2021TermsAndConditions_cList.get(0).policyName2 | WC$sep2021TermsAndConditions_cList.get(0).policyNumber2
#end
I've also tried this and again for empty fields I just see the full printed script in the email.
#if ( !$sep2021TermsAndConditions_cList.get(0).policyName2.isEmpty() )
<br /> $sep2021TermsAndConditions_cList.get(0).policyName2 | WC$sep2021TermsAndConditions_cList.get(0).policyNumber2
#end
When I tried this nothing was output even when the policyName2 field was not empty:
#if ( $sep2021TermsAndConditions_cList.get(0).policyName2.isEmpty() )
<br /> $sep2021TermsAndConditions_cList.get(0).policyName2 | WC$sep2021TermsAndConditions_cList.get(0).policyNumber2
#end
I'd love any guidance on where I'm going wrong or if there's a better way to evaluate null/empty values in Marketo Custom Object fields. Thanks!
... View more