- 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 01:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 03:51 AM
Cant we implement the same on Reference type ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 04:02 AM
You will need to write a advanced scripted reference qualifier to remove duplicates and display it on the reference variable. This is not a recommended approach, You should not allow duplicate group names on your group table and prevent it from creation by marking the unique flag on the name column on sys_user_group table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 01:46 AM
May i know What is the reason you have multiple group names with same name?
Thanks,
Siva