- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 01:38 AM
Hello,
We have a variable Reference Type which is referring to Assignment Group. Our Assignment Group contains duplicate group names ex: Test Group, Test Group, Network, Network
From the Catalog view when the user clicks or search for the Assingment Group we need to display only unique value like if the user types Network, it should display only Network once not multiple
How to acheive this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 11:02 PM
Last one may not work, This was tougher than I thought, I would really suggest you control the duplicate names at the table level for cost center, This is really not a recommended approach.
I have tested this script and it works, Please try this out
getUniqueCostCenters: function(){
var ccList = [];
var uniqueArr = [];
var ids = [];
var arrayUtil = new ArrayUtil();
var cc = new GlideRecord('cmn_cost_center');
cc.query();
while(cc.next()){
ccList.push(cc.name.toString());
}
uniqueArr = arrayUtil.unique(ccList);
ccList = [];
for(var i=0; i<uniqueArr.length; i++){
var cc1 = new GlideRecord('cmn_cost_center');
cc1.addEncodedQuery('nameIN'+uniqueArr[i]);
cc1.query();
if(cc1.next()){
ccList.push(cc1.sys_id.toString());
}
}
return 'sys_idIN'+ccList.toString();
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 11:41 PM
It is working when i run background script but when i search from the catalog view i see only 1 record 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 11:43 PM
Did you replace the function in your script include? Can you paste a screenshot here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 11:44 PM
Its working now i removed toString from the return statement and it got worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 11:46 PM
Thank you Ali, Chalan & Siva you all are genious 🙂
Hoping to be like you guys 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 11:53 PM
Hello Irfan,
Thanks for the compliment but i can say Ali bro(based on community replies and his technical oriented answers) and chalan(as i know in person) are geniuses 🙂
Thanks