How to use a check box as a condition in an IF statement in a Advanced PDF/HTML temple
Answered
I have a custom check box on a sales order and if this is checked I want another custom field to display on the sales order PDF. I have tried the below IF statement but it is throwing an error. How do I check if a checkbox is ticked in an IF statement?
<#if record.custbody_custom_address == “T”>${record.custbody_entity_id}</#if>
Best answer
We use the following snippet to indicate a note on the PDF.
<#if record.custbody_specialitem == true><b>This is a special item.</b> Expect a phone call to coordinate further information</#if>
Thanks! that’s worked 🙂
Just for future reference: To Solve errors while using condition on Checkbox in PDF template like 'For "#if" condition: Expected a boolean, but this has evaluated to a sequence+hash+string' etc.
<#if (record.custbody_specialitem?is_boolean && record.custbody_specialitem) || (record.custbody_specialitem?is_string && record.custbody_specialitem == 'T')