The CreatorCon Call for Content is officially open! Get started here.

org.mozilla.javascript.NativeArray@1a1047f

Wade Clairmont
Tera Guru

I have a watchlist on a form, and when I query the table to split the values of this field, only a few (5 out of 90) I receive a org.mozilla.javascript.NativeArray@1a1047f error when I try to process the values.

Would be fine if this was static across all records in that table, however, it only occurs on some of the records.  I have verified the values in the watchlist field, they are valid references to the user table on a valid one and one that receives the error.

Any one seen this before?

Thanks in advance.

 

1 ACCEPTED SOLUTION

Try adding toString() before you split

 

var fac = new GlideRecord('u_facility');
fac.query();
while(fac.next()){
var distlist = [];
var distlistnew = [];
var distlistrem = [];


if(fac.u_watch_list != '') {
distlist = fac.u_watch_list.toString().split(',');
gs.print(distlist); // displays ERROR
var distlistlen = distlist.length;
for(i=0;i<distlistlen;i++){
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id', distlist[i]);
usr.query();
while(usr.next()) {
if(usr.active == true){
distlistnew = distlistnew + usr.sys_id + ',';
}
else {
distlistrem = distlistrem + fac.u_facility_name + ' - ' + usr.name + ',';
}
}
}
fac.u_watch_list = distlistnew;
fac.update();
}
}

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Can you share the script which is causing this error? Seems to be some error because of array.

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Abhinay Erra
Giga Sage

 

Can you post the code here

Wade Clairmont
Tera Guru

var fac = new GlideRecord('u_facility');
fac.query();
while(fac.next()){
var distlist = [];
var distlistnew = [];
var distlistrem = [];

if(fac.u_watch_list != '') {
  distlist = fac.u_watch_list.split(',');
  gs.print(distlist);                             // displays ERROR
  var distlistlen = distlist.length;
  for(i=0;i<distlistlen;i++){
    var usr = new GlideRecord('sys_user');
    usr.addQuery('sys_id', distlist[i]);
    usr.query();
    while(usr.next()) {
      if(usr.active == true){
        distlistnew = distlistnew + usr.sys_id + ',';
      }
     else {
      distlistrem = distlistrem + fac.u_facility_name + ' - ' + usr.name + ',';
    }
  }
}
fac.u_watch_list = distlistnew;
fac.update();
}

Now, one thing to note as well, I have ran the exact same code in production and there are no errors.  We cloned PRD to TEST about 3 weeks ago, could this be a lost reference to a user record?

Try adding toString() before you split

 

var fac = new GlideRecord('u_facility');
fac.query();
while(fac.next()){
var distlist = [];
var distlistnew = [];
var distlistrem = [];


if(fac.u_watch_list != '') {
distlist = fac.u_watch_list.toString().split(',');
gs.print(distlist); // displays ERROR
var distlistlen = distlist.length;
for(i=0;i<distlistlen;i++){
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id', distlist[i]);
usr.query();
while(usr.next()) {
if(usr.active == true){
distlistnew = distlistnew + usr.sys_id + ',';
}
else {
distlistrem = distlistrem + fac.u_facility_name + ' - ' + usr.name + ',';
}
}
}
fac.u_watch_list = distlistnew;
fac.update();
}
}