This article is relevant if you are looking to generate XML files from NetSuite.
Background
As a NetSuite Systems Integrator, our work commonly has us create NetSuite integration to third-party systems. At times, we need to generate Extensible Markup Language (XML) files to transmit to a remote system. In my experience, the most common use case for XML file requirements is when we are building a warehouse or third party logistics (3PL) integration. I have designed so many of these and the capacity of every party varies widely.
XML is a popular file structure as it is self-describing, hierarchical, and can be validated. These days, I see more JavaScript Object Notation (JSON) as it is lightweight compared to XML. Like comma-separated value (CSV) files, these two document formats are all string-based.
There is no easy native way to generate XML (or JSON files) in NetSuite. I can share with you that I have been invited to work with many new customers to address where a previous consultant crafted a custom script to generate XML file that needs enhancement; while I can understand why others may have produced an XML using a NetSuite script, I would avoid it if I could. The pure script approach is difficult to develop and maintain. Fortunately, there is a much easier way.
Introducing Building Blocks to Easily Generate NetSuite XML Files
There really are three major components needed to more easily generate a NetSuite XML file:
- Data Source: we need some source of data; saved search comes to mind. But often this requires more than one saved search to get the required data together.
- XML Template: we want to be able to describe the XML through a template definition that will act in a mail/document merge like function.
- Transform and Output: we then want to take the data source and the XML template and meld them together to produce an output that will land in a file system.
This development pattern has proven to be effective in many document generation tasks.
NetSuite Tools Available to Produce the XML Document Generation Pattern
At this point, I like to share how my practice has created a number of tools that make NetSuite XML generation easy. All of these tools are free of license charge for our client enjoyment.
- Data Universe: In my article, Join Multiple NetSuite Saved Searches to Build a Data Universe, I describe how we have solved the challenge to link multiple saved searches together. Note, we can even join summary (aggregate) searches to each other and reference data. I can’t overemphasize how this capacity helps solve many NetSuite “data reach” challenges.
- Template Generation: In my 2015 article, Supercharge NetSuite Advanced PDF/HTML Templates, I describe how you can accelerate your PDF / HTML development with our Content Renderer Engine (CRE). This tool can work to output any string-based information — thus generating XML (and JSON) is swift and intuitive.
- Transformation and File Placement: once you have the data universe and the template definition, we offer two template generators (Freemarker and TrimPath) to blend together the data to get the desired XML content. We then couple a dynamic mechanism to name the resulting files and place them in the desired location on the NetSuite file system.
Altogether, I have placed some screenshots (click on images) to help show how the tools make the analyst more productive.
A Word about XML Distribution
Once your XML files are generated, they then will likely need to be distributed. Our Content Renderer Engine has a built-in mechanism to email them dynamically to target recipient(s). A more common technique is to use FTP/sFTP to transport the files to a remote server for hand-off and consumption. Readers can review my article, NetSuite sFTP Transfers Made Easy, to learn how we built a tool to make it easier for NetSuite administrators to set up and control file transfers in a managed fashion. Certainly, we can use HTTPS POSTs techniques which we commonly see using REST techniques.
Get Expert NetSuite Leadership to Drive Technology Requirements
While it is feasible to purchase third-party tools to drive these kinds of solutions, our approach allows for non-technical (and technical folks alike) to get control over the situation by leveraging the built-in power of the NetSuite platform. Since our tools are available without a license charge, there are no recurring fees; and we have found that our clients which are more technical in nature use our team to help train them to become self-sufficient.
If you found this article useful, feel free to receive notifications of new articles as I post them. My ethic is to not solicit. If you have a NetSuite XML challenge, let’s have a conversation.