16

On what version of javascript does netsuite currently run SuiteScripts?

This is my understanding: SuiteScript is a NetSuite scripting API that runs on a javascript engine. Javascript has multiple versions (E.G. ES6 and ES7). Which version does this engine use? Or, maybe I should be asking "What javascript engine does SuiteScript run on?". Then I could look up which version of javascript that engine runs on?

Let me give a practical example of what I'm getting at. In javascript version ECMAScript 7, you can declare an async function, but you cannot in ECMAScript 6. Can I declare an "async function" in SuiteScript? (arbitrary example)

  • 2
    Does that netsuite thing have any tech support or forums of their own at all? Or any documentation whatsoever? – Rob Jan 28 '18 at 03:36
  • Seems like a question for their forum: http://usergroup.netsuite.com/netflex/index.php – Tieson T. Jan 28 '18 at 03:50
  • As described in [this SO answer](https://stackoverflow.com/a/40977416/1545773) NetSuite is running running Rhino 1.7. – Maria Berinde-Tampanariu Jan 28 '18 at 11:27
  • 2
    Can someone explain why this question gets down-voted or link me to SO documentation that explains what makes a question worthy of being down-voted? My reasoning is that I searched NetSuite docs and google for this question but couldn't find an answer. What has historically made SO so valuable to me is that you can google an IT question and immediately see the SO response in the results. This is a foundational NetSuite question. Does NetSuite have no place in SO because it's so proprietary? – Andrew Castellano Jan 29 '18 at 05:28
  • 1
    Andrew, The best source for NetSuite's documentation is to log into your NetSuite account and click the help link in the top right corner. From there you can search the documentation for the specific information you need about SuiteScript. – w3bguy Jan 29 '18 at 13:23
  • 3
    I attempted that, but like most searches in the Help documentation, it proved fruitless. Are you able to find the javascript version in that Help documentation? If so, I would be genuinely interested how you found it. I must be a product of this information age, but if I can't find the answer to such a foundational NetSuite development question within 10 minutes of searching, then it's my opinion that there is a problem with the documentation. (And I've spent more than ten minutes now because I've attempted to find this answer on at least three different occasions now.) – Andrew Castellano Jan 29 '18 at 16:26
  • I noticed this is marked as unclear, let me try to clarify. Correct me where I'm wrong: SuiteScript is NetSuite scripting API that runs on a javascript engine. Javascript has multiple versions (E.G. ES6 and ES7). Which version does this engine use? Or, maybe I should be asking "What javascript engine does SuiteScript run on?". Let me give an example. In javascript ECMAScript 7, you can use [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), but you cannot in ECMAScript 6. Can I use arrow functions in SuiteScript? (arbitrary example) – Andrew Castellano Jan 29 '18 at 16:50
  • 1
    Hey Andrew, yeah, as far as I can tell, Netsuite help does not list the Javascript version (and I've spent a lot of time there). – M. Pope Feb 14 '18 at 18:55
  • 1
    Also this may seem unrelated, but people downvote for all sorts of random reasons. Something I like to do for Netsuite questions is leave out the Javascript tag though (it may help so that the people who see your questions are focused mainly on Netsuite) – M. Pope Feb 14 '18 at 19:01

3 Answers3

10

For Server side, I believe it is ECMAScript 5 (or so it has worked that way for my purposes). So no async/await, sorry. You can use your own implementation of Promises (or use Suitescript 2.0 which includes promises). Client side depends on the browser that's running it, so you could use async if it's supported in your coworkers browsers.

The server-side Javascript runs on Rhino (not sure of the version) which is different from Node.js and plays a bit more like a browser environment with no access to window. Certain limitations are placed on the backed (no XMLHTTPRequest, instead, you have to use one of their builtin methods, etc).

M. Pope
  • 411
  • 6
  • 16
  • 1
    This is corroborated by a third party website I found (by Googling "Netsuite ECMAScript") that claims at SuiteWorld 2017, Oracle announced that they were now supporting ECMAScript 5. From what little I've attempted to use it, this is confirmed by my experience. I have not found any statements in the official documentation regarding this other than a mention of ECMAScript 5 in a section about "SCA SEO Page Generator Best Practices" (not about SuiteScript in general): "You should not use functions that are not supported by the ECMAScript version 5 (ES5) standard." – Darren Ringer Mar 13 '18 at 20:19
  • Thank M. Pope, I voted up as helpful, but didn't select as the answer since there's no official source for the info. – Andrew Castellano Jun 06 '18 at 16:36
  • 1
    Just as a quick point of clarification here: from what I can gather from NetSuite's SuiteScript docs, SS 2.0 only supports promises for client-side scripts, so for anything server-side you'd still be out of luck. – YellowApple Oct 16 '18 at 22:04
  • SS 2 supports third party libraries, so a promises implementation like [Q](https://github.com/kriskowal/q) could be used. – Enzoaeneas Mar 22 '19 at 23:35
8

Just to update everyone: As of Suitescript 2.1 ES9 is supported so now you can have serverside promises and async/await.

symbiotech
  • 1,277
  • 2
  • 17
  • 29
Adolfo Garza
  • 2,966
  • 12
  • 15
1

https://www.netsuite.com/portal/resource/articles/erp/suitescript-21-delivers-modern-javascript-syntax-for-server-side-development.shtml

The money quote:

For a complete overview of all ECMAScript features, please refer to the 2019 Specification.

Which is version 10.

2019 Specification

Gerard ONeill
  • 3,914
  • 39
  • 25