Conditional logic lets you control what appears on your NetSuite Advanced PDF templates. Using FreeMarker tags like <#if>, <#elseif>, and <#switch>, you can show or hide fields, format values differently, or display alternate text depending on the record data.
This is powerful for handling multi-subsidiary, multi-currency, or client-specific layouts.
πΉ Basic <#if> Condition
<#if record.status == "Paid">
<p><b>Thank you for your payment!</b></p>
</#if>
βοΈ Shows the message only if the transaction is paid.
πΉ <#if> / <#else> Example
<#if record.terms?has_content>
<p>Payment Terms: ${record.terms}</p>
<#else>
<p>No Payment Terms Assigned</p>
</#if>
βοΈ Prevents empty sections when no value exists.
πΉ Checking Numeric Values
<#if record.total > 1000>
<p><b>High Value Transaction</b></p>
</#if>
βοΈ Only triggers if invoice total is greater than 1000.
πΉ Using <#elseif> for Multiple Cases
<#if record.subsidiary == "1">
<p>Bank: HSBC London</p>
<#elseif record.subsidiary == "2">
<p>Bank: RBC Toronto</p>
<#else>
<p>Bank: Default Account</p>
</#if>
βοΈ Useful for multi-subsidiary bank accounts.
πΉ Checking if a Field Has Value
<#if record.custbody_project_code?has_content>
<p>Project Code: ${record.custbody_project_code}</p>
</#if>
βοΈ ?has_content ensures the field is not blank before displaying.
πΉ Using <#switch> for Cleaner Logic
<#switch record.currency>
<#case "USD">
<p>Currency: US Dollar</p>
<#break>
<#case "CAD">
<p>Currency: Canadian Dollar</p>
<#break>
<#default>
<p>Currency: ${record.currency}</p>
</#switch>
βοΈ Best when handling multiple options (like currencies or shipping methods).
πΉ Conditional Logic in Line Items
<#list record.item as i>
<tr>
<td>${i.item}</td>
<td>
<#if i.quantity > 10>
Bulk Order
<#else>
Standard Order
</#if>
</td>
</tr>
</#list>
βοΈ Dynamically labels orders based on quantity.
πΉ Example: EU VAT Display
<#if record.shipcountry == "DE" || record.shipcountry == "FR" || record.shipcountry == "IT">
<p>VAT Number: ${record.custbody_vatnumber!"N/A"}</p>
</#if>
βοΈ Shows VAT only for EU shipping countries.
β Best Practices
- Always use
?has_contentto avoid printing blank values. - For multi-subsidiary setups, use
<#switch>to manage cleaner logic. - Combine logic with CSS for conditional formatting (like highlighting overdue invoices).
- Test with multiple records to confirm correct behavior.
β Summary β What You Learned
By the end of this section, you now know:
- β
How to use
<#if>,<#else>, and<#elseif>for conditions. - β How to check numeric and text field values.
- β
How to use
<#switch>for multi-option handling. - β How to apply conditional logic inside line items.
- β Practical business cases (multi-subsidiary bank accounts, EU VAT, bulk orders).
This builds the foundation for the next topic: Tables & Line Item Formatting, where youβll learn to style, group, and subtotal line items.
Leave a Reply