Array in client script Help!!!

malu
Tera Contributor

Hi All, I have a assignment group list array in client script I want NOT to show a field if incident assignment group contains one of this group.

var arrayList = ['test1','test2','test3'];

13 REPLIES 13

That is the expected output right to exclude None from the list?

the new array won't contain the None option

Regards
Ankur

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

yeah it should exclude none , but by using above code it wont exclude 

If the field value is as below.

find_real_file.png

If the field value is as below then it will work

find_real_file.png

So i wanted it to work for the 1st case.

Hi,

so if the only value is --None-- then you don't want to exclude

Only when None is present with other values you want to exclude

update as below

var field= current.getDisplayValue('list_field').toString();

var field2= field.split(',');

if(field2.length == 1 && field2[0] == '--None--'){

// use field2 directly no processing

}

else{

var newArr = [];

for(var i=0;i<field2.length;i++){

if(field2[i] != '-- None --'){

newArr.push(field2[i].toString());

}

}

gs.info('final arr without none' + newArr);

}

Regards
Ankur

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

ArrayUtil won't work in client side scripting. I have tried it.

Jatin_0-1669106342796.png