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

Hi @Ankur Bawiskar 

I have a similar requirement

Like:

I have field (List field- dropdown with None), and we calling this field into email subject along with other fields by notification email script, So now we dont want to display none in the subject even if the user select by mistake

 

Basically we just want to remove --None-- 

 

find_real_file.png 

@Thousif S N 

when you print that value in email script what it shows for --None--

You can accordingly exclude that value

Regards
Ankur

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

@Ankur Bawiskar  yeah it shows -- None -- if i print in the email script and same thing will be displayed in the email subject which we want to avoid

 

var field= current.getDisplayValue('list_field').toString();
var field2= field.split(',');
var field3= field2.splice(field2.indexOf('-- None --'), 1);

 

here i m printing field3 , this what the logic i have written but it doesnt seems to be working

Hi,

try iterating and create new array

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

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

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

@Ankur Bawiskar  Thank you for the response If i go with the above code it will work only when list field contains only '-- None --' in it if it has along with none other values then it wont work it will display all the values with none