The advanced template editor allows you to customize your templates to meet your specific needs. Here, you will find instructions on how to modify basic template properties and template layout settings.
To access the Template Setup window, simply click on the "Template Setup" button. Once the window is open, you can make the following modifications:
1. Basic template properties:
- Title (name): Give your template a clear and descriptive title.
- Description: Provide a brief description of the template's purpose.
- Preferred transaction type: Specify whether this template is preferred for a specific type of transaction.
- Script ID: This field is automatically assigned if left blank.
- Saved Search Template: Generate a template based on an existing saved search (only available for Saved Search templates).
- Template inactivation: If necessary, you can deactivate a template.
2. Template layout settings:
- Page orientation: Choose between portrait or landscape orientation for your template.
- Page size: Select the appropriate page size for your template.
- Margins: Adjust the margins of your template as desired.
For more information on how to save your advanced templates, please refer to the "Saving an Advanced Template" section.
We hope this guide has been helpful in improving your capabilities with NetSuite. If you have any further questions or need assistance, feel free to explore the provided resources. Happy editing!
Editing the template source code:
An advanced template is used to print a PDF file and is written in XML using syntax similar to HTML. It includes elements from the FreeMarker library and the BFO report generator. Here's an example:
<?xml version="1.0"?>
<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<pdf>
<head>
</head>
<body>
Hello, World!
</body>
</pdf>
The first line of the template declares the XML version, and the second line specifies the DOCTYPE. The template uses the BFO <pdf> wrapping tag instead of the <html> declaration found in HTML documents.
Inside the <pdf> tag, the head and body elements contain standard HTML. You can also embed CSS2 elements, but HTML5 declarations are not allowed. In the example, the text "Hello, World!" is displayed. For more information about the Big Faceless Report Generator, see the BFO User Guide.
In XML, elements must always be closed. So, <pdf> must always be matched by </pdf>, <b> by </b>, and so on. For elements that have no content, like <br>, the closing tag is included in the element: <br />. Attributes must be enclosed in quotes, for example, <table width=”100%”>.
If the PDF template is used for HTML printing, the <pdf> tags are automatically converted to <html> when the document is printed.
Important: If you encounter any issues with NetSuite advanced templates, please contact NetSuite Support.
BFO Elements
BFO (Big Faceless Organization) is a Java application used to convert XML documents into PDF files. NetSuite utilizes BFO, and for version details, refer to Third-Party Products Used in Advanced Printing. The following sections describe some commonly used BFO elements.
Page Numbers
The most commonly used BFO elements in PDF templates are page numbers and total pages. The <pagenumber /> and <totalpages /> tags insert the current page number and the total number of pages. These values can't be used as values in FreeMarker declarations because they are known only during the rendering of the page.
Headers, Footers, and Background Macros
BFO functionality allows you to define macros to repeat pieces of HTML code on every page. Each macro is defined in the head part of the template using the <macrolist> tag. You can reference the macro in the <body> tag definition to apply it. Templates do not support multiple headers, and header and footer macros must have a declared height to be applied. Here's an example:
<?xml version="1.0"?>
<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<pdf>
<head>
...
<macrolist> <!-- Definition of macros -->
<macro id="nlHeader"> <!-- Regular macros -->
... Header Content ...
</macro>
<macro id="nlFooter">
... Footer Content ...
</macro>
<macro id="nlWatermark">
... Footer Content ...
</macro>
<macro id="nlAltHeader"> <!-- Alternative macros -->
... Header Content ...
</macro>
<macro id="nlAltFooter">
... Footer Content ...
</macro>
<macro id="nlAltWatermark">
... Footer Content ...
</macro>
</macrolist>
...
</head>
<body header="nlHeader" header-height="2.5in" footer="nlFooter" footer-height="0.5in" background-macro="nlWatermark">
... Body Content each page with regular header, footer and watermark ...
<pbr header="nlAltHeader" header-height="2.2in" footer="nlAltFooter" footer-height="0.3in" background-macro="nlAltWatermark" />
... New page with alternative header, footer and watermark ...
... After that each page with regular header, footer and watermark ...
</body>
</pdf>
Note: If you experience issues with your advanced template, please contact NetSuite Customer Support.
Bar Codes
Advanced printing templates support various types of bar codes and QR codes listed in the Barcodes section of the BFO User Guide. To include a bar code, create a field with a value that corresponds to the bar code type. Here's the syntax for a QR code:
<barcode codetype="qrcode" showtext="false" height="150" width="150" value="http://www.example.com/" />
Using FreeMarker to Include NetSuite Data
FreeMarker is a Java library used to generate text outputs based on templates and dynamic data. NetSuite utilizes FreeMarker, and for version details, refer to Third-Party Products Used in Advanced Printing. You can use FreeMarker expressions to include NetSuite data in your template. An expression is written as ${record.entity}, and it will be replaced with the corresponding value in the output. Here are a few common uses for FreeMarker declarations:
Referencing Fields
FreeMarker is commonly used to reference fields on transaction records. To reference a field, use the syntax ${record.fieldId}. This will be replaced with the field's value in the output.
If you want to print the field's label, use ${record.fieldId@label}. For example, ${record.entity@label}: ${record.entity} can display "Customer: Fabre Art Gallery" on a Sales Order record.
Sublists and Other Lists
Some components in NetSuite can be referenced as a list of objects. For example, an item sublist on a transaction is represented as a list of lines. You can access the values of these lists using the index number ${record.list[index]}. For example, ${record.item[1].itemName} in a sales order will return "Green T-Shirt".
Another way to access a list is by using the FreeMarker #list declaration. Here's an example:
<#list record.item as item>
${item_index} ${item.itemName@label} ${item.itemName} --- ${item.amount}
</#list>
If the sales order's item sublist has three lines, the output will be:
0 Name: Blue T-Shirt --- 10.00$
1 Name: Green T-Shirt --- 12.25$
2 Name: Yellow T-Shirt --- 11.00$
When the sublist ID is the same as the field ID, @list is added to the sublist ID. The correct syntax is automatically displayed in the Fields selector. Here's an example of accessing a sublist:
<#list customer.currency@list as customerCurrency>
${customerCurrency.currency} <br/>
${customerCurrency.balance}
</#list>
To view the sublists supported for a record, refer to the SuiteBuilder Advanced Templates Reference. For more information about using FreeMarker expressions in advanced PDF/HTML templates, see Using FreeMarker to Include NetSuite Data. The training video available on the page describes how to include field IDs and sublists from NetSuite transaction records in advanced templates.
Additional Information to Include on Templates
Each template can access additional models, including companyInformation (Company configuration information), preferences (user preference settings stored as Boolean values), and user (user information).
Some templates have additional models attached, allowing access to more data. For example, you can access the customer record on each statement with ${customer.email}.
You can also use ${record@title} to print the record title.
Differences from HTML 4 Specification
The BFO and FreeMarker implementations have some differences from the HTML 4 specification, which may affect the formatting of your advanced templates. For more information, see the Element and Attribute Reference for BFO at http://bfo.com/products/reports/docs/tags/.
Certain characters behave differently with BFO. For example, the non-breaking space ( ) character is not rendered in advanced templates. Instead of using , use a line break element (<br />).
If you use for spacing in HTML table layouts, use the width and height attributes of the <td> tag to specify how BFO formats the <table> tag. Here's an example:
<table table-layout="fixed" width="200">
<tr><td width="60%">Cell 1</td><td width="40%">Cell 2</td></tr>
<tr><td>Cell 3</td><td>Cell 4</td></tr>
</table>
For more information about tables in BFO, see the BFO TABLE element documentation at http://bfo.com/products/report/docs/tags/tags/table.html.