Marty Zigman

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

How To: Leverage NetSuite’s Advanced PDF / HTML Generation Tools

NetSuite Reporting

Tags: , , , ,

This article is relevant if you are considering using NetSuite’s Advanced PDF/HTML Template technology to produce great looking documents.

Addendum

We are committed to this space.  Since we published this article in 2013, we have developed a number of other articles and tools that are most relevant for NetSuite users working to get more out of the Advanced PDF/HTML tools:

  1. Interrogating NetSuite’s Advanced PDF / HTML Templates
  2. Supercharge NetSuite Advanced PDF/HTML Templates
  3. Solved: Custom NetSuite Item Fulfillment Ship Notifications
  4. Framework for Generating Custom NetSuite PDF Files

Background

NetSuite’s standard document generator is basic. For the most part, the supplied documents, such as invoices or statements, gets the job done.  However, if you wanted more complex output formatting, you previously had to move to SuiteScript.

NetSuite uses a technology called “Big Faceless Organization” or “BFO” to enable PDF file generation driven by FreeMarker template engine.  A popular add-on in the Java community, these libraries are all built-in for us to use inside NetSuite behind the scenes.   Elements have been available to SuiteScript developers for a number of years through the SuiteScript nlapiXMLToPDF function call.

This also means that it has been beyond the reach of many NetSuite users.  However, more recently, the basic framework without the need for SuiteScript has been exposed via the “Advanced PDF/HTML Templates” feature. Once you enable this feature, you can user this tool to design your own PDF files without SuiteScript programming.

General Orientation

The template technology uses a framework that combines both XML, HTML, CSS, and BFO tags to drive the PDF generation. I have a sample invoice and the source code to help you make sense of what is happening.   Anyone with a good understanding of HTML and Cascading StyleSheets (CSS) should be able to get comfortable with this tool relatively quickly.

Header, Footer and Body Concepts

The first thing to realize is that NetSuite supplies sample templates with HTML snippets called a header, a footer and the body.   These concepts are easy to understand when we are in a document orientation.  These elements, which could have been named anything, are defined through a macro definition supplied by the BFO framework. The header and the footer then produce a page concept that repeats as the body content changes. The Body is meant to be where the main elements of your document (or report) is generated.

NetSuite Data References

The NetSuite documentation is still being developed. But here are some important concepts to understand:

  1. record: this is the primary data set you are referencing. If you are working with an invoice, you are effectively working with the equivalent of a transaction search and the results set of one invoice record object. Use the NetSuite Record Browser document located in Help for your field references.
  2. record.item: the record object has an item sublist, as well as others. The BFO framework has a way to setup loop in the document and then output the result. This tag “< #list record.item as item>” is a directive to trigger the framework to create a loop with the content located between the closing tag. It then supplies the “item” element information so you can reference the record’s sublist contents.
  3. companyInformation: this elements allows you to access the Company Information located under Setup, Company Information. For example, companyInformation.addressText will supply you your address defined globally. To get the field names, click the field label after you have activated Show Field IDs.

Subsidiary Information and One World

Unfortunately, the Subsidiary information is not accessible in the framework. Essentially, the Company Information is the root subsidiary.  Most of the time, your child subsidiaries are your operating entities.  You will  likely want to reference the Subsidary information as it contains key information about your subsidiary such as address, Tax ID, telephone and contact information.  Since you can’t reference the subsidiary records in the PDF framework, here is what you need to do:

  1. For every subsidiary field you care about, create an equivalent custom transaction body field.
  2. Source the default values for the custom field from the Subsidiary record.
  3. When the transaction record is created, the information will be copied from the Subsidiary and stored with the transaction.
  4. Reference this custom information now on the “record” object.

Ideally, all of the NetSuite elements would be exposed to the framework. However, this technique to source information from another table to your target table is a common practice when trying to expand features in NetSuite.

Trial and Error Development

I copy and paste the source code information between my favorite editor.  The process is iterative so be prepared to go back and forth many times to get the results you are looking for.

I also recommend you make local backups of your source document to disk.  The document format is XML — as such, the tag layout must be perfect for the document to be valid. If you mess it up as you develop, a common occurrence, it is helpful to have a copy of an old version that worked.

Summary

Creating your own document formats can trigger your customers to know they are working with a high caliber professional organization.  The new NetSuite PDF / HTML framework puts powerful document formatting within reach of most users comfortable with HTML.

If you would like help enhancing your NetSuite account, contact us.

Marty Zigman LinkedIn

Marty Zigman

Holding three official certifications, Marty is widely recognized as a top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. A former Deloitte & Touche CPA and technology executive with CTO roles, he brings over 35 years of leadership in ERP, CRM, and eCommerce business systems. Contact Marty to engage directly.

BiographyYouTubeLinkedInX (Twitter)

57 thoughts on “How To: Leverage NetSuite’s Advanced PDF / HTML Generation Tools

  1. Hi Marty–great article. Question: I’m looking to create a report from Netsuite using data from a saved search. Is that possible?

    Reply
  2. For clarification, I want a PDF generated out of netsuite, complete with company logo etc, but not just a standard form like what usually comes out of NS. Instead it would be a standard tabular report, based on a saved search.

    Reply
  3. Hi Marty, thanks for your post – I was trying to look at your ‘source code’ in the link in the body your post (just under ‘General Orientation’) but seems to be just a text version of your post? Do you have this available at all? Best Regards

    Reply
  4. A good cheat for finding any variable strings is to append the NS form page URL with &xml=t this displays the page as an XML page, simply search for the value that is in the field you are looking for and the string is in the XML tag next to it. Saved me hours!

    Reply
  5. Hi Marty,
    NetSuite has done another upgrade and some buttons and tabs are missing that enabled me to print thank you letters for our customers. How can find my stored letters/templates to continue sending the letters?

    Reply
  6. Hi, Marty. I want to catch item detail using ${item.item.custitemid} in sales pdf, is it ok? Custitemid is the custom item filed id. And I want to get all values of this field for all sublist item and to be print in sales order.

    Reply
  7. This article just saved my day. I am not a Netsuite developer but a request came to me from within organization to modify an exiting invoice. Going through documentation and your blog, I was able to accomplish 90% for design. But I was not able to get custom fields in the report and comment from “Dan” helped met get other 10%. And I just wanted to thank you for taking time to write this great article.

    Reply
  8. Hi Marty,

    I am creating a PDF using Xml files and in my xml file i am using to get the value of a list/record type field and getting the text value of that field because it returns only 1 value.
    But when i am tying to get the value of multi select type field using the same code and selects two more values for this fields i am getting value as undefined because it returns array of values.

    Please suggest how can i get all the selected values for multi select field.

    Thanks.

    Reply
  9. Hi Marty,

    I’m trying to print the expiration date corresponding to a lot number on transaction forms using advanced PDF templates. I know how I can do this using scripts, but I’d like to avoid scripting if possible. The problem is that inventorydetail contains info on Lot#, Bin#, and quantity but no expiration. Any idea how to grab the expiration date?
    Thanks!

    Reply
  10. Hi Marty,

    I’m trying to display item description on my pdf layout but result will be come with Html tags.my item description type is Inline html
    Result is:
    Receive off per month with your Act! Business Care* subscription.

    Reply
  11. I am trying to process a mathematical expression on the contents of a map of
    string data:

    —————
    | a | 1,111 |
    | b | 2,222 |
    —————
    so a simple expression like
    ${a?number + b?number}
    i want a result 1111+2222=3333

    but sytem give me following error

    The template cannot be saved due to the following errors:
    a is not a number, it is freemarker.template.SimpleScalar
    a is not a number, it is freemarker.template.SimpleScalar
    a is not a number, it is freemarker.template.SimpleScalar
    a is not a number, it is freemarker.template.SimpleScalar

    could you help me please……

    Reply
  12. Hi marty,

    Can we convert string to interger.
    e.g
    here s1=2 is string and s2=5 is interger
    now I want consolidated result like s1+s2=7
    is it possible?if possible then could you tell me how can i perform this operation.

    Reply
  13. Hi Marty,

    I have one custom field with lot of text and i want to print it on Advance pdf layout.but when I tried.it disaplying only some content of text on page and another text is not showing.so what can i do?
    do you have any kind of solution..

    thanks in advance…

    Reply
  14. Have you had success in getting to a linked sublist. I am trying to access the item sublist on a transaction from a custom record through a parent field. I thought it would be

    originalrecord.parentfield.sublist but no such luck

    Reply
  15. Hi Marty,

    I’m trying to create a template to be used for an email campaign.
    The Issue I’m coming across is that I cant get the “Dear [Customer Name]”, part of the merge to return a name from a Customer Contact record.

    Ideally we would like to be able to send a campaign to customer contact roles ie Director and then address the email to the related first name of the Contact.

    NetSuite support tells me that you can’t do this, but surely a function as basic as this for a mail merge should be possible within NetSuite.

    Having said this, I have managed to return some information from the $(customer.contact} tag, however it returns too much information.
    ie. [CompanyID] [CompanyName] : [“Primary Contact” first & lastname]

    I have tried to use javascript to truncate the section before and including the :, however this has not been successful.

    This only seems to be available for the “Primary Contact” Role also, so it will not meet all of our needs…

    Can you help me please?

    Thanks in advance!
    Brett

    Reply
  16. Hi Marty,

    In Advance PDF how to show the total amount in words like for e.g my total is 4500 and In words Four Thousand five hundred only…

    Reply
  17. Hi Marty,

    I need to display arabic text contents in the print layout. The text is saved in a netsuite field in the customer record. I can see the values properly when I open the customer record. But it is not getting rendered to the print layouts

    Reply
  18. To be specific, I have a customer requirement where he want to store item description in english as well as arabic. Then based on the requirement he would like to print invoices or quotes with english or arabic item descriptions. Customer name and address should also be printed in arabic if printing in arabic.

    Reply
  19. Hey Marty,

    Running into an issue trying to import XML into another XML file created by BFO (pdf). This PDF/XML generates our packing slips.

    Here are the page declarations for the main packing slip, and the below is located in the header file:

    <!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd"
    [

    ]>

    The ENTITY boxtype is giving this error with that box_type.xml file:

    Error Parsing XML: The element type “link” must be terminated by the matching end-tag “”.

    That box_type.xml has this simple test right now:

    BOX XXXXX

    BOX YYYYY

    That code works if I hard code it on the xml file where I’m trying to import the file. But that’s not going to be scalable if box types are constantly changing! Especially since we have over ~45 individual packing slips for different companies.

    Also if I set the entity to:


    [

    ]>

    It will put that on the PDF that is generated – test print.

    Any ideas or am I doing something that really isn’t supported well in Netsuite (importing another XML into XML)? Any workarounds if it’s the later?

    Thanks in advance Marty!

    Cheers,

    Mark

    Reply
  20. Hi Marty,

    Can you help me with the requirement where I need to implement Digital Signature in Advance PDF template. ?
    I refered the link:
    https://bfo.com/products/report/docs/userguide.pdf
    I used the code mentioned in this pdf with input tag. But its giving me error.

    Concerns:
    1. Do we need to have separate module (BFO module) for this functionality.
    2. Whether it supports only specific versions.
    3. What should be my approach to achieve this functionality.

    Any help would be appreciated.

    Thanks,
    Priyanka

    Reply
  21. Hi Marty,

    i’m trying to get items from work order sublist, using free-marker but i’m not able to get items, can you please help me i wrote code like given below.

    ${item.item}

    but this code works for invoice and sales-order record.

    Reply
  22. Hi Marty,

    New to Netsuite and suitescript after 25 years a developer, your columns have been a fantastic resource. Clear, concise, logical and a great help.

    I am probably teaching my gramma to suck eggs but give Notepad++ a try. It will highlight XML errors as well as automatically save files locally.

    Not a plug! One of my top dev. tools.

    Now back to trying to find my templateId from name.

    Reply
  23. Hi Marty,

    Do you happen to know if when generating a PDF from transaction in Netsuite we can assign a specific file name sourced from the records fields? IE for invoices I would like to code the file name upon generation as something like: {customer_name}_{entity_name}_{documentnumber}. Is this possible with Netsuite advanced html templates?

    Reply
  24. Hi Marty I want the field withholding tax amount can be added in advance html/pdf but it never work the amount nevers show, the field of withholding tax never show in report.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *