Developing in NetSuite — what it’s really like!

The NetSuite platform allows customizations via 3rd party code. This is a review of what development for NetSuite is all about.

Language

NetSuite solely uses JavaScript, referred to by NetSuite as SuiteScript. Using JavaScript on the client side most developers would be familiar with, but NetSuite also uses it on the server side. A lot of business logic can therefore be run either on the client or server side, or both. Although seemingly beneficial, in practice there will be few occasions where this will prove useful. The positive is that the NetSuite core libraries are identical on the server and client side, so it’s easier to learn.

As an example, let’s look at the API to get the contents of a remote URL: nlapiRequestURL. This API connects to the url passed in as parameter and returns an object containing details of the response. For SuiteScripts, this API is available in client and server scripts, which is kind of cool because cross site scripting limitations mean you can’t do this kind of thing on the client side directly. So what NetSuite does is pass it through the server (behind the scenes) when it’s called from the client side. It’s one less thing for developers to worry about, it’s just that the request will take longer.

Client side

Using JavaScript makes client side development very powerful. Because JavaScript can be used to manipulate the Document Object Model, a developer can do just about anything such as including external JavaScript from other websites. As an example, this is how we created this TotalCheck address validation integration. But because NetSuite uses neither jQuery nor Prototype, it either means going back to basics, or you need to include jQuery yourself.

Server side

On the server side, the NetSuite core libraries are very basic, apart from all the built-in APIs to manipulate the NetSuite data, helper libraries, such as an XML parser, are not built in. Also, because NetSuite is fairly unique in using JavaScript on the server side, you will also struggle to find many helpful community open source libraries. Nowadays backend developers are spoilt by frameworks such as Ruby on Rails or Django and have all the tools at their disposal such as geo-location libraries, XML parsers, image processing, and integrations with 3rd party services such as Amazon S3. Nothing like that will be available for JavaScript.

Script types

NetSuite has these four main types of scripts: Client, User Event, Scheduled, Suitelet. There are more types but these 4 will highlight all the possibilities of the platform.

Client scripts are exactly what you’d think, they run on the client side. You can write code on a set of events which happen on a client form: page init, field change, save, etc. These handlers are intended to perform custom input validation but you can do very advanced client side stuff as there is no limit to what JavaScript can be executed.

User Event scripts run on the server side, in response to records being opened or saved. The script runs on the server side. In particular the “Before Save” handler is useful as you can use it to make further modifications to records when they are updated.

Scheduled scripts can be run on the server at scheduled intervals. Apart from the obvious use case, to run certain checks on a daily basis, these types of scripts are also used to deal with script governance. A script is only allowed to take a certain amount of time and resources. So if your script has been running for too long, you can write code to handle this elegantly by rescheduling itself immediately. This doesn’t mean it executes over several days: when a script invokes a scheduled script it is run almost immediately again, this just seems to be the way NetSuite manages the server load.

Suitelets are also server side scripts and behave like web apps. This script type allows you to build up custom pages and forms, and handle GET/POST requests from them. NetSuite has a library which lets you build up a NetSuite-style form in your Suitelet, but you can also create custom HTML output.

Governance

All script types enforce governance, which means you can only use a limited number of resources per script execution. This is to prevent scripts running on the NetSuite servers from taking too long or putting too much of a load on the server. For client scripts there are also governance limits, which apply to the APIs which interact with the server side.

Development environment

When you want to develop an app for NetSuite, you can get a free development environment. The environment seems to be fully functional and it comes with accounts for two developers. When you are ready to release your code you can create a bundle using SuiteBundler. You can control where to deploy your bundle or you can even make it publicly available.

Trade-offs

So, on one hand developing in NetSuite is quite powerful. There is really not much that cannot be done. But like many things in NetSuite, this comes at the trade-off of ease of use. In terms of the development framework, this means it doesn’t have some of the features that mature platforms nowadays offer out of the box, such as:

  • No source code version and release management. This is sorely missing from NetSuite. To make a change to your code, you upload a new version of a file to the file library. When you collaborate with other developers this can cause problems. You need to implement your own deployment strategy while your app is under development.
  • No testing framework. Modern, mature frameworks have us spoilt with all the tools to do coverage testing, automated unit testing and regression testing. NetSuite offers nothing of the sort, which is especially painful given that JavaScript is not a compiled language.
  • No ability to store application values. Something like the registry on Windows. There is no ability to store for example simple name/value pairs. The only way to store persistent data is by creating records.
  • Lack of server side libraries. I’ve named some examples before. Not having the in-built ability to for example parse XML is something you can work around but it just means more work to build apps. Partly because JavaScript is the server side language, there are no communities providing libraries either.

Summary

If as a developer you are choosing a platform to develop for, NetSuite is not an obvious choice. Be prepared to read a lot and spend a lot of time developing things from scratch. But if you are being asked to create an app for a customer who already uses NetSuite, what the client asks for is almost certainly possible, because there are almost no limits to what can be customized. But with power comes great responsibility.