SOLVED

Re: Script token with an integer field not working

Go to solution
Kassia_Wilhelm
Level 2

Script token with an integer field not working

I have a script token that checks to see if one of our integer fields is over 9; if it is over 9, I want the html in the token to display, if it's less than 9 I want no html to display in that area. I wrote the velocity script correctly syntax-wise, but the "#if FIELD > 9" comparison is not working.

I created an integer variable and added a parseInt function and it works, but then the email that it's used in won't Approve - it throws up this error message:

0EM50000000SKoX.jpg

Does anyone have any idea how I can get the token to satisfy Marketo? Is there another function that can be used rather than parseInt to make the comparison valid?

Here is the token code:

#set($Integer = 0)
#if (($Integer.parseInt(${lead.Domain_Use_in_Past_Year__c})) > 9)
<table align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="40">
</td>
</tr>
<tr>
<td align="center" style="font-size:18px; color: #A5A9AC; font-weight:100;">
${lead.Domain_Use_in_Past_Year__c}
</td>
</tr>
</table>
#end

Any help is appreciated!
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Kassia_Wilhelm
Level 2

Re: Script token with an integer field not working

Wanted to update this post in case anyone experiences a similar issue.

This is what eventually worked for me to use a parseInt-type function:

<tools>
   <toolbox scope="application">
     <tool class="org.apache.velocity.tools.generic.ConversionTool" dateFormat="yyyy-MM-dd"/>
   </toolbox>
 </tools>
 
 #set( $DomainCount = $math.toInteger(${lead.Domain_Use_in_Past_Year__c}) )
#if( $DomainCount > 9 )
<table align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="40">
</td>
</tr>
<tr>
<td align="center" style="font-size:18px; color: #A5A9AC; font-weight:100;">
${lead.Domain_Use_in_Past_Year__c}
</td>
</tr>
</table>
#end

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Re: Script token with an integer field not working

Do you have the checkbox on the right enabled for your "Domain Use in Past Year" field?
Kassia_Wilhelm
Level 2

Re: Script token with an integer field not working

Yes! I've made that mistake in the past, not this time!
Kassia_Wilhelm
Level 2

Re: Script token with an integer field not working

Wanted to update this post in case anyone experiences a similar issue.

This is what eventually worked for me to use a parseInt-type function:

<tools>
   <toolbox scope="application">
     <tool class="org.apache.velocity.tools.generic.ConversionTool" dateFormat="yyyy-MM-dd"/>
   </toolbox>
 </tools>
 
 #set( $DomainCount = $math.toInteger(${lead.Domain_Use_in_Past_Year__c}) )
#if( $DomainCount > 9 )
<table align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="40">
</td>
</tr>
<tr>
<td align="center" style="font-size:18px; color: #A5A9AC; font-weight:100;">
${lead.Domain_Use_in_Past_Year__c}
</td>
</tr>
</table>
#end
Anonymous
Not applicable

Re: Script token with an integer field not working

This saved me a bunch of time! Thank you for posting your solution.
Diane_Condon1
Level 1

Re: Script token with an integer field not working

Thanks Kassia! This was really helpful.

Diane
SanfordWhiteman
Level 10 - Community Moderator

Re: Script token with an integer field not working

Diane Condon​ you'd likely enjoy this complementary post on my blog.

Note you don't need to include $convert -- it is already in the context.