- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 05:12 AM
Hi Team ,
Am using below code to check the bytes length for string field ,code is working fine in global scope .But throwing below error for scoped application .
Please guide me
var str = "Testing length";
var utf8Bytes = GlideStringUtil.base64DecodeAsBytes(GlideStringUtil.base64Encode(str));
gs.print(str + utf8Bytes.length);
Error:
Evaluator: com.glide.script.RhinoEcmaError: Cannot find function base64DecodeAsBytes in object function GlideStringUtil() { [native code, arity=0] } . script : Line(2) column(0) 1: var str = "Testing length"; ==> 2: var utf8Bytes = GlideStringUtil.base64DecodeAsBytes(GlideStringUtil.base64Encode(str)); 3: gs.print(str + utf8Bytes.length);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 05:38 AM
then it's not supported in scoped app.
you can create script include in your global scope and make it accessible from all scopes and then use the script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 05:21 AM
what's your business requirement?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 05:27 AM
We're currently examining the string fields to ensure they don't surpass 255 characters. If they do, we need to limit the user or trigger an alert. To handle this, we've implemented client-side scripting:
- We're converting strings to bytes and assessing the byte length.
- While this code functions well globally, it's encountering an error when used within the application scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 05:38 AM
then it's not supported in scoped app.
you can create script include in your global scope and make it accessible from all scopes and then use the script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 06:27 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader