- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 11:05 AM
Is there some who could explain why the Javascript string.padStart function doesn't seem to work in ServiceNow?
Example to run in the background script editor:
var myval = '67';
var zeropad = myval.padStart(8, '0');
gs.info(myval);
gs.info(zeropad);
gs.info('done');
Execution results in display of "undefined" for zeropad
*** Script: 67
*** Script: undefined
*** Script: done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 11:10 AM - edited 08-30-2024 11:16 AM
This was introduced in ECMAScript 6 or later and the scripting engine that ServiceNow uses is based on ECMAScript 5. Since Tokyo, you can use ES12 in scoped applications, and starting with the Xanadu release, supposedly all server scripts even in the Global scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 11:10 AM - edited 08-30-2024 11:16 AM
This was introduced in ECMAScript 6 or later and the scripting engine that ServiceNow uses is based on ECMAScript 5. Since Tokyo, you can use ES12 in scoped applications, and starting with the Xanadu release, supposedly all server scripts even in the Global scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 11:23 AM
Thanks Brad! I suspected something like that but I like definitive answers and you provided one 😊