Advanced Archive File Manipulation In SuiteScript

Author: Luke Pirtle, Director of IP Development

Overview:

This guide is technical in nature and details how to successfully unzip any archive file or folder inside of NetSuite and store the results in the file cabinet without the use of a middleware. While the compress module exists it is not sufficient for heavy lifting and this solution can resolve many use cases not supported by the official module.

Background:

When it comes to unzipping files most languages such as C++, Python, .NET, it’s mostly an afterthought. Even JavaScript can unzip files as numerous libraries exist but it’s not always straight forward to use most Node.js libraries inside the NetSuite ecosystem. The challenge is getting a library that works in the SuiteScript AMD module loader with minimal polyfill functions that doesn’t use ECMA script exceeding your current SuiteScript standard.

Due to these limitations the best solution is to add a middleware or redesign things completely. However, I recently ran into an unavoidable use case and neither was a satisfactory path. After extensive research and testing I’ve found a lightweight no hassle solution to work with archived files / folders. At some point NetSuite might release updates to the compress rendering this unnecessary but until then this should address these issues

Solution:

he solution is simply the impressive JSZip library but getting the library to work in NetSuite is not simple
https://stuk.github.io/jszip/

Version:

This is the key and most important piece. The current version of the JSZip library is 3.X and utilizes some impressive asynchronous functions and patterns for better performance. Despite trying every syntax and asynchronous method this new version is incompatible with the ECMAScript standard and NetSuite configuration in SuiteScript. Every permutation will eventually break right before reading the file contents.

However, the 2.7 version works and doesn’t include the asynchronous components. This stripped down version has all the capabilities without the unnecessary advanced asynchronous features and is fully compatible with the 2.1 SuiteScript ECMA script configuration.

Loading the module in a Suitelet:

NetSuite uses an AMD (Asynchronous Module Definition) loader. This is the biggest hindrance in getting Node.js modules to work. Fortunately, JSZip has a minified singular file that can be dropped into NetSuite. Below I detail how I load the module but I’ve also included the author’s notes on how it’s loaded in the system to give a full picture of what is happening.

Working with 2.7

I have the minified JSZip file in my project library folder and below demonstrate how to load it.

This allows the creation of new JSZip Instances to work with archives. With this configuration, the issue is much more straight forward now as we only have to write code. Sample code is detailed further down and documentation on the older version can be seen in their upgrade guide linked below
https://stuk.github.io/jszip/documentation/upgrade_guide.html

Sample Code

This solution below loads an archive file which is a folder with ~numerous files of differing types and is an excellent example. The code reads the archive file using the N/file module, then it iterates through each file and then creates a corresponding file in the file cabinet.

In my code snippet above you’ll notice the references to base64, this is because NetSuite uses base64 for essentially everything non-plaintext and files are no exception. Fortunately JSZip can handle this. Grab the contents of your archive file via N/file use the “getContents()” method to return the base64 content of the archive file. Drop that into the JSZip initialization (line 64) with the base64 argument set and now you have a valid JSZip Archive instance object loaded via SuiteScript. To create files you’ll simply need to iterate through the files subobject and then run the JSZip “file” method to read the contents. When creating files in NetSuite you’ll need to once again consider base64. Text is needed for text files and Base64 for anything else. To determine what is needed, look at the file extension. Once you have encoded your file simply save it and you now have a file committed to the file cabinet. Below I have a text reference for copying and utilizing in your own solutions.

Plaintext Reference for (Ctrl + C):

let extensionMapping = {
    'XML': file.Type.XMLDOC,
    'html': file.Type.HTMLDOC,
    'PDF': file.Type.PDF,
    'JPG': file.Type.JPGIMAGE,
    'BMP': file.Type.BMPIMAGE,
    'xlsx': file.Type.EXCEL,
    'txt': file.Type.PLAINTEXT,
    'json': file.Type.JSON
};

let plainTextTypes = [
    file.Type.CSV,
    file.Type.XMLDOC,
    file.Type.HTMLDOC,
    file.Type.PLAINTEXT,
    file.Type.JSON
];

let archiveFile = 57163;
let archiveFolder = 56852;
let xactimateTestArchiveTargetFolder = 2510;

let zipFileObj = file.load(archiveFolder);
let bin = zipFileObj.getContents();

var ZipInstance = new JSZip(bin , {base64: true});
for (let fullPathFileName in ZipInstance.files){
    if (fullPathFileName.indexOf('.' !== -1)){
        let fileName = fullPathFileName.split('/').pop();
        let fileExt = fileName.substring(fileName.lastIndexOf('.') + 1).toUpperCase();
        let netsuiteExt = extensionMapping[fileExt];
        log.debug({title:`File to ${ netsuiteExt ? 'Create' : 'Ignore' }`, details:`FileName: ${fullPathFileName}, fileType:${fileExt}, NetSuiteType: ${netsuiteExt}`});
        if (netsuiteExt){
            let data =ZipInstance.file(fullPathFileName).asBinary();
            if (plainTextTypes.includes(netsuiteExt) === false){
                data = JSZip.base64.encode(data);
            }

            let zippedFile = file.create({
                name:fileName,
                folder:xactimateTestArchiveTargetFolder,
                contents:data,
                fileType:netsuiteExt
            });
            zippedFile.save();
        }

    }

}

Caravel Partners Recognized by NetSuite as Summer 2022 Alliance Partner Spotlight Award Winner

We are excited to share that Oracle NetSuite has named Caravel Partners, A BPM Technology Solutions Company, a Summer 2022 Alliance Partner Spotlight Award Winner for Software.

NetSuite’s Alliance Partner Spotlight Awards recognize leading partners and their achievements for outstanding work with customers, including:

  • Demonstrated commitment and success in implementing NetSuite
  • Development of outstanding expertise, customizations and/or intellectual property in specific microverticals
  • Demonstrated commitment to and success in implementing NetSuite Analytics Warehouse, OpenAir, SuiteCommerce and NetSuite Planning and Budgeting

The NetSuite Alliance Partner program provides business consulting services, as well as integration and implementation services, that help customers get even more value from their NetSuite software. Alliance Partners are experts in their field and have a deep and unique understanding of NetSuite solutions.

Caravel Partners continues to show expertise in the Software and High-Tech industry with the goal of helping companies grow.

“We are honored to be recognized for the hard work our teams have put in to ensure the success of our software and high-tech customers. Our goal remains the same for all our clients, help drive the right decisions as quickly and as cost-effectively as possible”.

Tai Valenzuela, Director of Strategic Operations

Having worked with over 500 clients, Caravel has consolidated this experience into a repeatable framework for helping companies define lean yet scalable business processes, efficiently determining the right technology to support the business, deploying the software platform, providing project oversight to ensure project and ultimately business success and providing ongoing support services as needed.

5 Reasons to Use Cloud ERP to Automate DCAA Compliance

5 Reasons to Use Cloud ERP to Automate DCAA Compliance

Whether securing their first government contract or acquiring larger opportunities, companies of all sizes need a DCAA compliance solution that’s built into NetSuite Cloud ERP to create a complete business management solution. Here are five reasons why:

1. A requirement for any organization that wants to do business with the DoD, DCAA compliance ensures that all of its trading partners are using proper financial management techniques in the course of business. Responsible for performing all audits for the U.S. DoD and for providing accounting and financial advisory services to DoD components responsible for procurement and contract administration, the DCAA also provides contract audit services for other government agencies.

2. Where the Lockheed Martins and Raytheons of the world may have complex systems in place to ensure DCAA compliance, small to midsized businesses (SMBs) don’t always have these resources at their avail. A smaller organization that relies on older, on-premises software systems and Excel spreadsheets to run its operations, for example, may be caught off guard upon being awarded its first government contract. An excellent opportunity to expand its horizons, the company may quickly find itself mired in the idiosyncrasies of maintaining DCAA compliance. 

3. If you’re awarded a government contract, the government agency will request detailed information regarding contract-related transactions such as procurement, revenue, and time entry postings. DCAA also mandates how you structure and report against your financials. These requirements directly impact how a company sets up its chart of accounts, reports on that chart of accounts, and then manages financial allocations. Handling these responsibilities manually or using disconnected, on-premises software systems is both time- and labor-intensive, not to mention error-prone. By automating these processes on a unified cloud ERP platform that includes pre-built DCAA compliance capabilities, companies of all sizes can easily gather, retain, and generate everything they need to win a contract and maintain compliance. 

4. Without a centralized system to refer to, companies also grapple with poor operational visibility for their government contracts. When sales, procurement, and fulfillment managers can’t collaborate on a single system, they must resort to emailing spreadsheets and documents back and forth every time a company has to produce a report or a specific document to the DCAA. 

5. Once in place, the DCAA SuiteBundle automates time entry, labor costing, accounting, billing, and reporting in a way that disparate solutions and spreadsheets can’t match. The SuiteBundle also makes the DCAA’s strict payroll and time-keeping requirements much easier for SMBs to manage. And while some solutions on the market tackle just the time-keeping task, Caravel Partners enhanced the NetSuite Cloud ERP time entry module to be able to handle all of DCAA’s time-related specific requirements.  

Caravel’s DCAA Compliance SuiteBundle is built directly into NetSuite and supplements the functionality that companies need to comply with DCAA rules and regulations. The DCAA SuiteBundle can be implemented either during or post a base ERP implementation, with the typical time frame spanning four to five months (for both the ERP and the SuiteBundle). 

By automating processes and tasks that were previously handled manually, the DCAA SuiteBundle frees up employees to focus on more important projects. It also provides an excellent audit trail for DCAA and its third-party audit agencies. 

Whether your company is on the verge of winning a large government contract and in need of its first DCAA compliance software or already using one and unable to handle the complexities of larger contracts, NetSuite ERP plus the pre-built DCAA SuiteBundle can accommodate organizations of all sizes and across all industries.

A Unified ERP Solution for DCAA Compliance | WhitePaper

Whether securing their first government contract or acquiring larger opportunities, companies of all sizes need a DCAA compliance solution that’s built into NetSuite Cloud ERP to create a complete business management solution.

Every year, the U.S. federal government spends trillions of dollars procuring the goods and services that it needs to keep its many different departments running. In 2020 alone, it spent $6.55 trillion, [bm1] a portion of which involved deals with government contractors, the largest of which includes well-known organizations like Lockheed Martin, Boeing, General Dynamics, and Raytheon.

Download our WhitePaper to learn more.

Webinar 4.8.21 | High-Tech: Why NetSuite Edges Out Intacct in High-Tech

Join us on Thursday, April 8th at 11:00 AM PST, for an in-depth look at the differences between NetSuite and Intacct and why NetSuite continues to be the #1 ERP for High-Tech.

Caravel Partners will be covering the below topics:
– Industry Pain Points in High-Tech
– NetSuite Solution Configuration
– NetSuite vs Intacct Comparison
– Integrations & Improving Visibility

*Agenda subject to change

Presenters

Scott Curry | Managing Partner

Matt Hayton| Managing Partner

Caila Cohen | Solutions Engineer

Dates and Times:

April 8, 2021 11:00 AM PST

Shipping Integration with NetSuite ERP

Learn How NetSuite’s Quality Management Bundle Can Help Your Business

Designing, manufacturing, distributing, and selling a product of high quality does not happen by accident, it requires a company-wide commitment to enforcing policies and standards. NetSuite’s Quality Management solution has been designed to help you deliver the highest quality in your products with minimal overhead regardless of the size and complexity of your business and product line.

 Key Benefits 

  • Formalize quality policies, standards, and practices. 
  • Improve product quality. 
  • Initiate quality activities from business transactions. 
  • Work with large volumes of raw data sets. 
  • Collect in-process and incoming inspection results. 
  • Compare to the pass/fail criteria. 
  • Integrated non-conformance reporting. 
  • Reduced cost of quality.

Inspections 

The inspection record defines exactly what it is that you want your quality engineer to check. These inspection records can be re-used so, for example, you only must create a “check for material certificates” inspection once—these are later grouped into specifications that are then applied to items, etc. There are currently two main types of inspections that are supported. 

With qualitative inspections, the inspector can verify that the item is in good overall condition or verify that the appropriate certificates are in place. Quantitative inspections, on the other hand, allow you to define multiple measurable elements along with criteria for acceptance, i.e. diameter, width, length, temperature, or even chemical composition.

Skip Lot, Sample Size and Failures 

Within each inspection, you can also specify how many items need to be inspected and define rules for inspecting specific sequences of lot or serial tracked items. Failures then define how many of the inspected units can fail inspection before the inspection itself is failed—kicking off the non-conformance workflow. 

As an administrator, you are able to distinguish sample data from summary or aggregate data and control whether sample data should be recorded in NetSuite or stored externally, allowing you to easily work with larger volumes of raw data sets. 

Test Definition 

Each inspection can be set up with multiple data elements that define the parameters of the inspection process.

Fill out the form to view the webinar and opt-in for future Caravel updates!

Fill out the form to view the webinar and opt-in for future Caravel updates!

Fill out the form to view the webinar and opt-in for future Caravel updates!

Fill out the form to view the webinar and opt-in for future Caravel updates!

Fill out the form to view the webinar and opt-in for future Caravel updates!

Fill out the form to view the webinar and opt-in for future Caravel updates!

Fill out the form to view the webinar and opt-in for future Caravel updates!

Fill out the form to view the webinar and opt-in for future Caravel updates!

Fill out the form to view the webinar and opt-in for future Caravel updates!

Fill out the form to view the webinar and opt-in for future Caravel updates!

Stay In Touch

Register for our newsletter and all other updates that the Caravel team has to share!