org.mozilla.javascript.NativeArray@3d4ce6 on the variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 08:23 AM
I am trying create an array from the multi line text field that will have group names on new lines.e.g
so in the script i am checking if the array actually getting created or not
var str = current.variables.group_list.toString();
var grpArr = str.split("\n");
current.variables.test_array = grpArr;
& i am getting the error on the field where i am trying to submit the array to test.
Can someone tell me what this error is OR any other way i can check array is getting created or not For further uses in the script.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 08:25 AM
Hi there,
I would expect that this is a variable of type list collector for example? So actually sys_ids comma separated? Can you confirm?
You are performing a split on \n now, though that sounds not valid if it indeed is a list collector type variable with actually sys_ids comma seperated.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 08:34 AM
Hi
it contains the groups names after the first line of add access.
i actually have to add below script on approval activity to create approval for all the group managers of groups mentioned in the field.
But even after this script the approvals are not getting created.
answer = [];
var str = current.variables.group_list;
var grpArr = str.split("\n");
for(var i=1;i<grpArr.length;i++){
var gr = new GlideRecord('sys_user_group');
gr.addQuery('name', grpArr[i]);
gr.query();
if(gr.next()){
var manID = gr.manager;
if(manID){
answer.push(manID.toString());
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 09:43 AM
Hi,
Did you check any space at the end of the group name
try this
answer = [];
var str = current.variables.group_list;
var grpArr = str.split("\n");
for(var i=1;i<grpArr.length;i++){
var gr = new GlideRecord('sys_user_group');
gr.addQuery('name', grpArr[i].trim());
gr.query();
if(gr.next()){
var manID = gr.manager;
if(manID){
answer.push(manID.toString());
}
}
}
Regards
Ankur
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-10-2020 08:29 AM
Just an example of values from a List Collector:
06ca6a70db0b77800c1741efaa96198b,4d269f66dbfe9c100ef53232399619a1,a9a305e3db442200b3aa7a0bbf9619cd,1ea345e3db442200b3aa7a0bbf961933,aaa345e3db442200b3aa7a0bbf961954
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field