how is javascript version configured for server side global scope scripts?

Dave Oshinsky
Tera Expert

I have a Utah PDI where I'm writing both "Fix Scripts" and Scripted REST API logic with global scope. The version of Javascript that's running appears to be really archaic - no support for "class" or "let".

 

I see here that the Javascript version is configurable, but I don't see anywhere so far explaining how to change it:

https://docs.servicenow.com/en-US/bundle/utah-application-development/page/script/JavaScript-engine-...

 

It seems that the default global scope Javascript in my Utah PDI is the ancient "compatibility" mode, based on no support for newer features like "class" or "let" (instead of "var").

 

Assuming I figure out how to change the setting to a more modern Javascript, the next question would be:

what happens when one of my scripts is deployed to another instance (perhaps non-Utah, perhaps non-PDI)?  Will the Javascript version setting have to be manually changed there (if I use more modern features like "class" and "let")?

1 ACCEPTED SOLUTION

OlaN
Giga Sage
Giga Sage

Hi,

Newer versions of JavaScript is only implemented in Scoped Applications. It's NOT available (yet) in Global scope.

You can read more on the Docs site.

 

View solution in original post

9 REPLIES 9

OlaN
Giga Sage
Giga Sage

Hi,

Newer versions of JavaScript is only implemented in Scoped Applications. It's NOT available (yet) in Global scope.

You can read more on the Docs site.

 

I saw that page, mentioning "The default mode for new scoped applications is ECMAScript 2021 (ES12) and for new global applications is ES5 Standards.".  I somehow got confused that ES5 has "class" and "let".  After checking again, I see that those were introduced in ES6 (2015), while ES5 is dated 2009 and lacks "class"/"let". Thanks for the explanation.

The application I'm working on must be able to access any resource in a ServiceNow resource, not just those tables etc. within a particular scope. As a result, I'm forced to write these server side scripts (ultimately destined for Scripted REST API's because basic functions like table creation are missing from the OOB REST API's).  Having mostly worked in Java/C++/C#, I'm still in more than a bit of shock having to write Javascript code (while I'm learning the language) using a very archaic version.  Not fun...

Yeah, I can feel your pain. ServiceNow is getting kinda old.. 😁

 

Did I get this right, are you going to create tables in ServiceNow using REST ?