Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The NetSuite Pro

The NetSuite Pro Logo The NetSuite Pro Logo

The NetSuite Pro Navigation

  • Home
  • About Us
  • Tutorials
    • NetSuite Scripting
    • Advanced PDF Templates in NetSuite
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Home
  • About Us
  • Tutorials
    • NetSuite Scripting
    • Advanced PDF Templates in NetSuite
  • Blog
  • Contact Us
Home/ Advanced PDF Templates in NetSuite/Conditional Logic in Advanced PDF

Conditional Logic in Advanced PDF

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.

Share
  • Facebook

Leave a ReplyCancel reply

Sidebar

Ask A Question

Stats

  • Questions 6
  • Answers 6
  • Best Answers 0
  • Users 2
  • Popular
  • Answers
  • Rocky

    Issue in running a client script in NetSuite SuiteScript 2.0 ...

    • 1 Answer
  • admin

    How can I send an email with an attachment in ...

    • 1 Answer
  • admin

    How do I avoid SSS_USAGE_LIMIT_EXCEEDED in a Map/Reduce script?

    • 1 Answer
  • admin
    admin added an answer The issue is usually caused by following Wrong script file… September 14, 2025 at 10:33 pm
  • admin
    admin added an answer Steps to send an Invoice PDF by email: define(['N/email', 'N/render',… August 28, 2025 at 3:05 am
  • admin
    admin added an answer This error means your script hit NetSuite’s governance usage limit… August 28, 2025 at 3:02 am

Top Members

Rocky

Rocky

  • 1 Question
  • 21 Points
Begginer
admin

admin

  • 5 Questions
  • 2 Points

Trending Tags

clientscript netsuite scripting suitescript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

© 2025 The NetSuite Pro. All Rights Reserved