I cant seem to get IF statements to work in Email ...
# administration
n
I cant seem to get IF statements to work in Email templates. Am I going crazy? Basing it off a checkbox. Tried T, true, TRUE, Y, Yes, yes, 1, 0. Even to a string. Here is my latest attempt from an online article. Please let me know if I am doing something wrong 🙂 <#if "record.custbody_includehelpguide?string" = "Yes"><a href="linktomedia">Help Guide</a><br /> </#if>
j
I sometimes find it helpful to log what the field is putting out. Like, exclude the if statement and just put the ${record.custbody_includehelpguide} in the document then preview it. That'll usually guide me to figure it out. So, if it comes out as 'T', then you can make it: <#if record.custbody_includehelpguide = 'T'>...
n
thanks. I tried that as well. transaction.custbody_includehelpguide returns Yes unfortunately <#if transaction.custbody_includehelpguide = 'Yes'> doesnt display the link. No error or anything 😞
j
isn't it
==
in freemarker when checking a true/false? Just one
=
assigns the variable But if it's a checkbox you should just be able to do
<#if transaction.custbody_includehelpguide>...
n
@Jon Kears - You would think. Works in advancedpdf BUT NOT in Email Template. <#if transaction.custbody_includehelpguide> will not save (error) <#if transaction.custbody_includehelpguide == 'Yes'> does not error but doesnt show link. Same with 'T', 't', 'TRUE', 'true', '1', 'Yes'
j
found an example that works for us in freemarker (untested in email template, but I don't see why it would fail)
<#if record.custbody_bill_dept_prefix_desc?trim == "Yes">
n
Thanks for looking for me, @Jon Kears ! That was kind of you to take time out of your day. Greatly appreciated. I'll test and post back.
That works but my mind is still blown. Why would that be?
j
Ha this is why we have the emoji netsuite . I guess it turns the boolean into a string (any string function might do similar) so the comparison works, but I thought this was supposed to happen implicitly.
🤣 1