Contact Us

A NetSuite developer should always practice caution when using code they did not write themselves. While there is no need to reinvent the wheel and manually type out every piece of code when samples of code are readily available (whether through subscriptions to code libraries or even code snippets available free for public use), copying code off of the internet to incorporate it into your solution can cause problems. Not only may there be a better way for you to write the code, but shortcuts may not work when using a coding language like SuiteScript, which through it is based on JavaScript, has key differences that will prevent certain code from functioning properly without making edits.

Common Cause of SuiteScript Extension Errors

If you are pulling publicly code snippets off of the internet to put into your NetSuite extension’s service file, make sure to reformat any shorthand arrow function expressions. If arrow functions stay in the code as is, you may get an “unexpected error” on deployment or a syntax error on activation. Understanding this is crucial for NetSuite developers aiming to build robust and error-free SuiteScript extensions.

Resolving the Arrow Function Error

Just a handful of characters would have to be added or converted to make the arrow function code workable in SuiteScript 2.x. For example, this line of code to find if an array of objects has some value in the object parameter “name":

if (arrayOfObjects.filter(e => e.name == "Select This").length > 0)

The above code would need to be converted into what you see below in order to function properly:

if (arrayOfObjects.filter(function(e) {return e.name == "Select This"}).length > 0)

Got stuck on a step in this article?

We like to update our blog articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!

Tagged with Troubleshooting