NetSuite development: Getting off the blocks…
Recently I have had a chance to work on NetSuite development. It took me some time to get familiar and then start doing development in NetSuite. In the process of learning NetSuite, I referred to a lot of websites, and NetSuite documentation. I have now started getting a better handle and confidence in how things work in NetSuite & what can/cannot be done in NetSuite. So far, I like it & it’s still a learning process.
In this process, I have learned a few things. the hard way and hence thought of consolidating my experiences and learning via a few blogs. It may save some time for newbies, onboarding on NetSuite.
Introduction: NetSuite allows customization through a SuiteFlex.SuiteFlex is the technology toolkit for data integration within the NetSuite platform. For developers, SuiteFlex provides a complete set of tools and APIs for accessing or modifying NetSuite’s records. NetSuiteTechniques-NetSuite’s most used techniques for data modifications are SuiteTalk and SuiteScript. SuiteTalk-SuiteTalk exposes NetSuite’s data as soap based web service. Using these APIs a developer can access NetSuite without using the web browser. An outside application or a third-party interface can communicate to NetSuite via SuiteTalk. SuiteTalk uses java or .net.
The following are common scenarios where SuiteTalk can be used to develop applications and services.
1. An application that performs data sync between NetSuite and an external database.
2. Importing data from CSV file into NetSuite.
SuiteScript-It is a javascript referred to by NetSuite as SuiteScript. Using javascript on the client-side is common, but NetSuite also uses it on the server-side. A lot of business logic can therefore be run either on the client or server or both. Client script allows connecting to any external URL. Behind the scene NetSuite is actually passing this call to the server-side, executing it, and returning back the response to the client side.
What SuiteScripts can do?
SuiteScript is considered the most powerful tool for NetSuite’s customization.
NetSuite has 4 types of scripts Client, UserEvent, Schedule, and Suite. There are other types as well but these will highlight most of the possibilities.
ClientScript allows you to show any alerts to display any message or other validity checks, just like JavaScript. But you can do advanced client stuff too. UserEventScript lets you modify the record; validate it, before it actually inserted to the
NetSuite database- ScheduleScript runs on the server after every scheduled interval. It can be rescheduled programmatically. e.g.If any client wants to receive an email every Monday morning consisting of Sales Order details or When any record needs to be checked periodically for any new changes, such cases, ScheduleScript is the only solution. Suite lets can create custom pages or forms. It can handle GET/POST requests. NetSuite provides a library that helps you to create a NetSuite-looking page. You can also create HTML output. Resource Usage Limit-This is a very interesting aspect of the NetSuite that I recently came across. Resource usage limit i.e. governance limit defined by NetSuite. NetSuite restricts resource usage per customer. SuiteScript thresholds are based on the volume of activity that a company’s user can generate.
In order to optimize application performance, NetSuite has implemented a SuiteScript governance Model based on usage limits. Usage units are tracked on two levels: the API level and the script type level. NetSuite has provided a getRemainingUsage () API that you can use to see how many units you have remaining for a particular script. The workaround for this is to break business logic into smaller parts. e.g. Sometimes there is a requirement where you have to create multiple records through the script and halfway script throws usage limit exceeded error if it exceeds the governance limit for that script. For creating every record you call nlapiSubmitRecord () which consumes 20 units per call. To handle such cases you can do the following check.
if( context.getRemainingUsage() >= 20) { //create record NlapiSubmitRecord(); } else{ //log message //return }
Development Environment-
When you want to develop an app for NetSuite, you can get a testing development environment. The testing environment is almost a replica of the production environment and is fully functional. Whenever any script is developed and ready to run it can be uploaded to the sandbox production server.? However, there is no full-proof guarantee that the script developed in the testing environment will give the same expected output in production. The developer always ends up making changes in the script in the sandbox to achieve the expected result.
Challenges in NetSuite Development-
NetSuite gives developers the ability to extend NetSuite beyond the capabilities provided by point-and-click customization. But like many things in NetSuite, this comes at the trade-off of ease of use. NetSuite doesn’t provide you basic development framework that any platform offers:
1. No testing framework -NetSuite offers nothing of that sort and it is quite painful to find a bug especially when you have to deal with non-compiled language like javascript.
To make a change to your code, you have to upload a new version of a file, to test every change. As NetSuite runs on the cloud every time uploading a file takes a lot of time which in turn increases the whole development time.
2. NetSuite version upgrades -After every 6 months, NetSuite releases a new version of the production and testing environment. And 90% of the time, existing apps or services break down because of the changes in a new version. NetSuite doesn’t provide any information about the kind of changes that are made or which records are unaltered. The developer has to test all the apps or scripts manually to ensure that none of the existing functionality breaks.
3. No track of code versioning-No ability to store application’s/scripts values. You can use SVN to keep track of the changes.
4. User experience -As no of scripts per record increases user experience for that record effectively decreases. If you have 10 UserEventScripts that must complete their execution before the record loads into the browser for the user, this significantly increases the time it takes for the record to load. As a consequence, the user’s experience working with the record is negatively affected.
5. NetSuite’s out-of-date documentation When I first started my development in NetSuite I was actually banging my head against the wall. I kept getting completely brain-fried trying to figure out whether I should be looking at the docs or suite answers.
On plenty of occasions, I have been caught out by outdated documentation. I think NetSuite kinda makes you believe that you learn better from your own mistakes! 🙂 Now I have started to know my way around.
These are the four things I usually follow:
1. Decide a type of script depending upon your requirement. You can select a type by looking at the APIs that are supported for every script type.
2. Refer to the code snippet provided by the guide. NetSuite’s Ad-hoc Debugging Technique lets you debug code fragments written on the fly. Try debugging these code snippets beforehand. ad-hoc debugging does not need any script deployment.
3. Refer to the schema browser and record browser provided by NetSuite.This guide helps you to understand NetSuite’s terminology for every field of every record.
4.Use nlapiLogExceution() API . This is useful during the debugging of a script or for providing useful execution notes useful for tracking purposes. Summary-I would say in spite of these challenges, NetSuite has made customizations possible and easy to some extent. Be ready to spend a lot of time reading NetSuite documents and developing things from scratch. With some exceptions, there is almost no limit to what can be customized in NetSuite and hence there is a pretty good chance to meet all your client requirements. I will continue sharing more specific experiences and nuances of NetSuite as I explore and get to know more of it.
Summary: I would say in spite of these challenges, NetSuite has made customization possible and easy to some extent. Be ready to spend a lot of time reading NetSuite documents and developing things from scratch. With some exceptions, there is almost no limit to what can be customized in NetSuite and hence there is a pretty good chance to meet all your client requirements. I will continue sharing more specific experiences and nuances of NetSuite as I explore and get to know more of it.