NetSuite transactions (Invoices, Sales Orders, Purchase Orders, etc.) contain standard fields (like tranid, trandate, entity) and custom fields (defined by your business). With Advanced PDF, you can use FreeMarker syntax to insert these fields into your templates.
This page covers how to display, format, and troubleshoot transaction fields in your Advanced PDF/HTML templates.
πΉ Displaying Standard Fields
<p>Invoice #: ${record.tranid}</p>
<p>Date: ${record.trandate?string("MMMM dd, yyyy")}</p>
<p>Customer: ${record.entity}</p>
<p>Status: ${record.status}</p>
<p>Total: ${record.total}</p>
βοΈ record = transaction record object
βοΈ ?string() = formats dates
πΉ Displaying Custom Fields
Custom fields start with custbody_ (body) or custcol_ (line).
<p>Project Code: ${record.custbody_project_code!"N/A"}</p>
<p>Sales Channel: ${record.custbody_sales_channel}</p>
βοΈ Add !"Default" to avoid blank values.
πΉ Handling Addresses
<h4>Billing Address</h4>
<p>${record.billaddress}</p>
<h4>Shipping Address</h4>
<p>${record.shipaddress}</p>
βοΈ These render multi-line addresses automatically.
πΉ Accessing Line Item Fields
<table border="1" width="100%">
<tr>
<th>Item</th><th>Description</th><th>Quantity</th><th>Rate</th><th>Amount</th>
</tr>
<#list record.item as i>
<tr>
<td>${i.item}</td>
<td>${i.description}</td>
<td>${i.quantity}</td>
<td>${i.rate?string["#,##0.00"]}</td>
<td>${i.amount?string["#,##0.00"]}</td>
</tr>
</#list>
</table>
βοΈ ${i.item} = Item name
βοΈ ${i.custcol_custom_field} = custom column field
πΉ Conditional Logic with Fields
<#if record.terms?has_content>
<p>Payment Terms: ${record.terms}</p>
</#if>
βοΈ Prevents blank labels when no value exists.
πΉ Example: Transaction Header Section
<div style="font-size:14px; font-weight:bold;">
Invoice #: ${record.tranid}
</div>
<div>Date: ${record.trandate?string("dd-MMM-yyyy")}</div>
<div>Customer: ${record.entity}</div>
<div>Currency: ${record.currency}</div>
<div>Sales Rep: ${record.salesrep!"Not Assigned"}</div>
πΉ Troubleshooting Field Issues
- Blank values β use
!"Default" - Custom field missing β check form access/permissions
- Wrong format β use
?string() - IDs instead of labels β use
@label
Example:
<p>Terms: ${record.terms@label}</p>
β Summary β What You Learned
By the end of this page, you now know:
- β
How to insert standard fields like
tranid,trandate,entity, andtotal. - β
How to display custom body and line fields (
custbody_andcustcol_). - β
How to render addresses directly with
${record.billaddress}and${record.shipaddress}. - β
How to loop through line items using
<#list record.item as i>. - β
How to apply conditional logic with
<#if>to prevent blank fields. - β How to troubleshoot common issues (empty fields, wrong format, ID vs. label).
This gives you a strong foundation to move on to Conditional Logic in Advanced PDF where youβll apply more complex <#if> and <#switch> rules.
Leave a Reply