Netsuite Blog

Home

Net Sweet!

A few years ago, I was introduced to Netsuite, a cloud-based ERP system. This new system was going to replace the existing Oracle EBS applications that was the backbone of a retail-based business focused on the consumer electronics industry. The organization decided to implement Netsuite using its own resources. As a result, I was part of a team of developers tasked with transitioning all existing business processes from Oracle EBS/ERP to Netsuite.

Prior to Netsuite, I had experience with several noteworthy ERP systems. None of them however, were cloud-based.

  • INFOR's Syteline was the very first ERP system I developed applications for. It was a Windows desktop-based system that required on-premise systems to run and support it. The application environment was form-based and with a SQL server back-end database.
  • EPICOR Vantage was the second ERP system that I developed applications for. The development environment was VB.Net for the application layer and Postgress 4GL for the database layer.
Netsuite finally introduced development to the cloud with its own version for code development called SuiteScript. Using Javascript technology, code development involved a basic knowledge of Javascript and understanding the exposed objects and properties for customizing and building business applications. Deploying code involved uploading the scripts to the Netsuite file cabinet, creating script records and deployment records using different SuiteScript types.

The biggest advantage of Netsuite, and any cloud-based system, is the convenience of working anywhere you have an internet connection to log into the Netsuite system. In terms of infrastructure, the whole environment is provisioned for your organization and none of it is on-premise. In terms of application development, the whole environment is cloud-based and you could technically develop using a browser-based IDE or use Visual Studio Code app, WebStorm or Eclipse IDEs.

I will be covering several techniques for code development and customizing Netsuite in this blog. Yes there will be actual working code that has been tested and running in a production environment that may be using undocumented features of NetSuite which may or may not break depending on when NetSuite updates the internal workings of their system. At this point we are not worried about that possibility because in reality, only 20% of the 80% of our worries ever come to pass (if at all).

So stay tuned for more because we are, after all, interested in finding real world solutions to real world problems!

Netsuite Blog

Home

Sweet Scripting

SuiteScript -- what the hell is that?

Scripting?! Isn't that a step backward you might say. How does that hold up or compare to actual compiled code?

Well let me tell you that working with SuiteScript in Netsuite is relatively easy to get used to once you understand the basic concepts of scripting using SuiteScript. I mean who wouldn't want to be free from having to install all the bloated development tools code just to output "Hello World!" to a web page?

SuiteScript consists of several script types for every type of development situation you might need to build your applications with.

  • User Events

    This is the script to use if you need to fire events triggered on forms by user interaction with the user interface or automated processes.
    Sample Code from NetSuite Help

  • Portlets

    This is the script to use if you want to customize user dashboards and/or provide quick links to anything.
    Sample Code from NetSuite Help

  • Suitelets

    This is the script to use if you need to build your own custom forms. For web developers, the paradigm is similar to web forms that accept GET and POST requests and return web responses that you can evaluate.
    Sample Code from NetSuite Help

  • Scheduled Scripts

    This is the script to use if you need to process records and schedule automated processes.
    Sample Code from NetSuite Help

  • Map/Reduce Scripts

    Recently introduced in version 2.0 of SuiteScript, these types of scripts are the preferred type because of the imposition of usage governance limits or to put it simply, preventing code from hogging cloud-based resources using parallel processing and better allocation of processor queues for automated processing.
    Sample Code from NetSuite Help

  • Client Scripts

    All types of scripts execute server-side except for this type. If you want to run client-side code, this is your only bet.
    Sample Code from NetSuite Help

  • RESTlets

    If you need to integrate external applications with Netsuite, RESTlets are the best way to do that. Suitelets are also a good candidate because like RESTlets, they accept GET and POST requests that you can process server-side. Think of RESTlets as your very own custom APIs into Netsuite.
    Sample Code from NetSuite Help


SuiteScript is not the only way to create applications in NetSuite. If you want to communicate directly with the NetSuite API because your business requirements need to take a different approach, SuiteTalk is another way of manipulating data outside of the NetSuite user interface. But that's another topic on its own for a future blog post.
Netsuite Blog

Home

Batch Processing

Use Case: You need to update Netsuite records using data from an external source with the data exceeding more than one page of NetSuite records (1000 records per page).

In order to update Netsuite records, you will need to use the internalid property to gain access to the record via script. If you need to match up more than 1000 records of external data with NetSuite records, you will need a way to process batches of 1000 records.

Here's an overview of the steps:

  • Collect the external data that contains a matching value for the Netsuite records you need to work with. This can be a custom field or a native Netsuite field that uniquely identifies the matching Netsuite record with the external data source. (e.g. UPC->upccode field in Netsuite).
  • Loop through the external data source field and assign them to a string variable stringing them together as comma delimited.
  • Pass the string to a function that builds the data object via another function that splits the data into a maximum of 1000 rows for each batch.

You can achieve this functionality with only three functions.

Note that code is in simple, basic, and easy-to-understand form, style and syntax for the purpose of making it easy to adapt for your environment.
Click for code view

Netsuite Blog

Home

Framed!

Use case: You just created a very nice custom form using a Suitelet script and you want to incorporate a saved search into this form. Displaying the saved search inside the Suitelet form presents a few challenges.

The first problem that you will encounter when trying to display a saved search using an iframe on a Suitelet form are the default Netsuite native controls because they're part of the Netsuite interface and iframes by default display the whole page and not just parts of it.

The best way to handle this is to use the DOM. Using client-side Javascript, you can hide those default Netsuite native controls. With this technique, you can use saved searches in an iframe on any Suitelet form.

You can achieve this functionality with a few lines of code.

Note that code is in simple, basic, and easy-to-understand form, style and syntax for the purpose of making it easy to adapt for your environment.
Click for code view
Netsuite Blog

Home

Side-by-Side Datagrids

Use case: Form sublists on Suitelets are a great way to display datagrids of data but how do you display them side-by-side?

Sublists are a great way of displaying data on a datagrid on Suitelet forms. Unfortunately, sublists can only be displayed either one at a time on subtabs or one on top of another on field groups or even on subtabs. If you want to display lists side-by-side on a datagrid layout, you will need to use some other technique such as utilizing datagrids from Datatables. In this example, we will combine data sources from a dynamically-generated search and a CSV file upload from the NetSuite file cabinet. Regardless of the how you source the data, you will learn how to populate an HTML page with data from NetSuite and a file-based source to display a side-by-side datagrid on a custom NetSuite Suitelet form.

Here's an overview:

  • Download the javascript and css style sheet from Datatables.
  • Create the HTML template for displaying side-by-side datagrids.
  • Create a Suitelet form and add an iframe that references the HTML template from the NetSuite file cabinet.

You can achieve this functionality with a combination of SuiteScript and Datatables code.

Note that code is in simple, basic, and easy-to-understand form, style and syntax for the purpose of making it easy to adapt for your environment.
Click for code view
Netsuite Blog

Home

Sweet World Of Wizards

Use case: You need a wizard-type user interface that can keep track of each process step.

If you've ever needed to import CSV data into Netsuite you would have used the Import Wizard. This is called an Assistant.

Netsuite's term for these types of wizards is an Assistant. Assistants are a type of form created on Suitelet scripts. They allow the user to move through every step of the process. Using assistants allow you to control and validate each step before moving to the next step of the process.


Code coming soon!
Netsuite Blog

Home

Buttoned Up!

Use case: Custom buttons that fire to execute custom client-side functions are possible in Netsuite.

Form buttons in Netsuite are created and handled using any of the following constructs:

  • form.addSubmitButton
    This is the default and oft-used method for creating a button that submits data to the form. You can trap for this button using the context.request.parameters.submitter syntax on a POST call.
  • form.addButton
    This is one way of firing a client-side function referenced by the form.clientScriptModulePath syntax.
  • form.addResetButton
    This button resets the values on the form. It doesn't refresh the page.
  • sublist.addRefreshButton
    This button is created on the sublist and refreshes the sublist. You don't need to write a function to make this work. You just need to define the button.
  • sublist.addMarkAllButtons
    This button adds a Mark All and Unmark All button to handle checkbox interaction (toggle checked and unchecked) to the sublist.

You don't need to be limited to these types of button declarations. You can create your own custom buttons with custom functions fired from client-side scripts that takes your Suitelets to the next level.



Code coming soon!
Netsuite Blog

Home

I REST my (use) case

Use case: You need to pull data from Netsuite with an external application but without using a 3rd party application or outside vendor.

You were just informed of the need to pull data from Netsuite to be able to analyze the data outside of Netsuite.

The easiest way to do that is to create a saved search and using the native NetSuite export functionality available via the toolbars, you can export data that way but that's native NetSuite functionality which is not the subject of this topic. We're more concerned about the technique for allowing an external application to communicate with NetSuite to retrieve records via automation. The only way to extract data without the use of 3rd party applications and plug-ins is by using a SuiteScript script type called RESTlets. RESTlets listen for GET and/or POST calls. RESTlets have external urls that you can use as endpoints for your external application.

The steps needed to achieve this are:

  • RESTlet
    Create a RESTlet and define the functions that will evaluate the parameters to pass on to either the GET or POST calls.
  • Authenticate
    Using OAuth 1.0 authentication methods, call the RESTlet using the RESTlet url.
  • Function call
    Pass the parameters to the function that will retrieve the data and return it in either CSV, JSON, or XML format.



Code coming soon!
Get in Touch

Contact