Using FreeMarker to Work with Hidden Fields Used in Advanced Templates
Advanced printing templates can fail to print when they depend on a sublist hidden field.
In the following custom transaction form example, the Show box beside the Corporate Card field box isn't checked. Therefore, Corporate Card is hidden from templates.

When a field is visible (box is checked), it's represented as a Boolean condition in the advanced template, like this:
<#if expense.corporatecreditcard == true>
"Corporate Card" is checked!
</#if>
When a field is hidden, you must instead compare the value of the field with a string: "T"(true) or "F"(false), like this:
<#if expense.corparatecreditcard == "T">
"Corporate Card" is checked!
</#if>
A template that depends on the Corporate Card hidden field is no longer valid because the type of box changes from Boolean condition to string. You can't compare a Boolean condition to a string.
If you use a string condition like the preceding example and then make the field visible, then this condition isn't valid.
Error Messages
If a template can't be printed because it depends on a sublist hidden field, you receive an error message similar to one of the following:
-
In this example from the template editor, the comparison of string with Boolean condition isn't valid:
-
In the following example, the second condition isn't valid because it can't be evaluated to true or false:
Template Editor Error Message
UI Error Message
Solution for Unknown Visibility of the Field
You should avoid a scenario where a template depends on a sublist hidden field.
If you don't know whether the field is visible, you should create a condition in which the template behaves correctly in both cases, like in the following example.
<#if (expense.corporatecreditcard?is_boolean && expense.corporatecreditcard) || (expense.corporatecreditcard?is_string && expense.corporatecreditcard == "T")>
"Corporate Card" is checked!
</#if>
Related Topics
- Source Code Editing in the Template Editor
- Source Code Editing to Customize Advanced Templates
- Syntax for Advanced Template Fields
- Setting a Template to Use a Font Unavailable in NetSuite
- Adding Files to Advanced PDF Templates
- Languages for Printed Forms that Use Advanced Templates
- Adding Translated Content in Advanced Printouts
- Adding Striping to Line Items in Advanced Templates
- Adding Page Breaks to Tables
- Printing Subsidiary Logo on Advanced Templates
- Adding Apply Sublist to Check Templates
- Adding Bar Codes in Advanced Templates
- XML Formatting in Advanced PDF/HTML Templates