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_content
to 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