- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 10:06 AM
Im trying to remove duplicated using ref qualifier and script include but after execution Im not getting any values at all.
What am I doing wrong?
Outcome:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 10:28 AM
Hi @Alon Grod ,
-If you don't have that site field should be of reference type it is best to go with lookup select box which is the best option for your requirement.
-Add the u_sites table under type specification and lookup value filed as name and if you want you can give the lookup label field(s) as name,location.
-Important one should be check the unique values only check box
Thanks
Accept as solution if it works for you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 10:28 AM
Hi @Alon Grod ,
-If you don't have that site field should be of reference type it is best to go with lookup select box which is the best option for your requirement.
-Add the u_sites table under type specification and lookup value filed as name and if you want you can give the lookup label field(s) as name,location.
-Important one should be check the unique values only check box
Thanks
Accept as solution if it works for you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 10:35 AM
It looks like your sites table has records with non-unique Names. Your reference qualifier doesn't make sense in that it's passing in the value of u_site which is going to be blank as that is the field the reference qualifier is on, so your Script include is returning the unique records in an empty array. To only show records with a unique name, use your reference qualifier without current.u_site. Your Script Include then needs to query the sites table, pushing each result to the resulting array only if the name is not the same as the previous record, so it would look something like this, assuming your table name is 'u_sites' and the name field is 'name':
var UniqueSites = Class.create();
UniqueSites.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isUnique: function(){
var storeArr = [];
var storeName = '';
var storeGR = new GlideRecord('u_sites');
storeGR.orderBy('name');
storeGR.query();
while (storeGR.next()) {
if (storeGR.name != storeName){
storeArr.push(storeGR.sys_id.toString());
storeName = storeGR.name;
}
}
return 'sys_idIN' + storeArr.join(',');
},
type: 'UniqueSites'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 10:39 AM
Hello @Alon Grod
Greetings!
try
site = [];
site.push(sites.getValue("sys_id")) //passing into array
or
site.push(sites.sys_id.toString()) ;
and get the unique value on site array
please mark the answer as correct and helpful based on Impact.
Kind Regards,
Ravi Chandra