When customizing Advanced PDF templates in NetSuite, errors can happen due to syntax mistakes, missing fields, or unsupported logic. This page lists the most common errors and how to fix them, so your templates run smoothly.
🔹 Error: Blank Fields Showing in PDF
Cause: The field is empty or not available on the record.
Fix: Use !"Default Text"
or ?has_content
.
<p>Sales Rep: ${record.salesrep!"Not Assigned"}</p>
<#if record.custbody_project_code?has_content>
<p>Project Code: ${record.custbody_project_code}</p>
</#if>
🔹 Error: Wrong Value (Internal ID Instead of Label)
Cause: Some fields return internal IDs instead of display names.
Fix: Use @label
.
<p>Payment Terms: ${record.terms@label}</p>
<p>Currency: ${record.currency@label}</p>
🔹 Error: “Unknown Variable”
Cause: The field ID is wrong, or not accessible.
Fix:
- Double-check the internal ID in Customization > Lists, Records, & Fields.
- Confirm the field is added to the form.
<p>Custom PO: ${record.custbody_customer_po}</p>
🔹 Error: Broken Conditional Logic
Cause: Incorrect FreeMarker syntax.
❌ Wrong:
<#if record.total = 1000> <!-- single = used -->
<p>Total is 1000</p>
</#if>
✅ Correct:
<#if record.total == 1000>
<p>Total is 1000</p>
</#if>
🔹 Error: Table Misalignment
Cause: Missing borders, inconsistent <td>
widths, or no padding.
Fix: Add inline CSS with consistent styles.
<td style="border:1px solid #ccc; padding:5px; text-align:right;">
${i.amount?string["#,##0.00"]}
</td>
🔹 Error: Numbers Not Formatting
Cause: Values are raw numbers.
Fix: Use ?string
.
<p>Total: ${record.total?string["#,##0.00"]}</p>
🔹 Error: Date Appearing in Wrong Format
Cause: Default format is raw.
Fix: Apply custom formatting.
<p>Date: ${record.trandate?string("dd-MMM-yyyy")}</p>
🔹 Error: PDF Fails to Load (Template Crashes)
Cause: Invalid FreeMarker syntax or unclosed tags.
Fix:
- Check for unclosed
<#if>
or<#list>
tags. - Validate HTML tags (
<tr>
,<td>
,<div>
). - Test step by step (comment out sections).
✅ Best Practices
- Always clone templates before editing.
- Test on multiple records (with/without values).
- Use
?"Default"
and?has_content
to avoid blanks. - Validate your FreeMarker with small changes.
- Keep a backup copy of your last working version.
✅ Summary — What You Learned
By the end of this page, you know how to:
- ✅ Fix blank fields using
!"Default"
or?has_content
. - ✅ Show labels instead of IDs with
@label
. - ✅ Debug unknown variable errors.
- ✅ Correct syntax mistakes in conditions.
- ✅ Format dates and numbers properly.
- ✅ Troubleshoot broken tables and crashes.
This sets you up for the next page: Real-World Advanced PDF Examples, where you’ll see complete invoice, PO, and statement templates.
Leave a Reply