remove duplicates from an array and get unique values

Vijay27
Tera Guru

var text=[];
text = new GlideRecord("sn_hr_core_hr_tasks_per_case_type");
text.addEncodedQuery("u_task_visibilityLIKE" + topicCat + "^ORu_task_visibilityISEMPTY");
text.addQuery("u_generation_type", "manual");
text.addNullQuery("u_auto_group_pref","test");
text.query();
while(text.next()) {

taskArray.push(text.getUniqueValue());

}

19 REPLIES 19

thanks bro but it ia huge task bcoz it includes another table to display tasks in popup,i coulnot able explain it to u.but the error is in returning some tasks but whenever i click ui action it is returning duplicates.if u know how to copy from one array to another plz let me know


var arr = ["k","v","s"];
var arr2 = arr.slice(0);
arr is copied into arr2

Thanks,

Siva

Can you please check if that solved your issue and Mark the appropriate response as correct and close this thread so that it can be removed from unanswered category 

 

Thanks,

Siva

 

Hello , 

 

Can you please check if that solved your issue and Mark the appropriate response as correct and close this thread so that it can be removed from unanswered category 

 

Thanks,

Siva

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,


Use this:

 

var arrayUtil = new ArrayUtil();
var a1 = new Array("a", "b", "c", "c", "b");
gs.print(arrayUtil.unique(a1));


https://community.servicenow.com/community?id=community_question&sys_id=9a3dc7a9db9cdbc01dcaf3231f961908

Thanks,

Ashutosh