Distinct or unique values on reference field / lookup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2015 10:58 PM
Hey all
On a form i have created a reference field which points to a custom table and this table has NO UNIQUE key.
So upon clicking the lookup icon, it should display only unique or distinct values like below it should show only 1200 and 1300.
VenID | Name |
1200 | ABC |
1300 | XYZ |
1200 | JKL |
I have made use of reference qualifier and wrote a code like
vendorIdList = arrayUtil.unique(vendorIdList);
This is working, but since the table has some thousands of records, its taking very long time to display the unique values.
Any other method to achieve this quickly.
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 06:15 AM
Hi Nikh,
I understand. I will recommend you give it a try to see how it goes . i don't think performance will be an issue and you can go through the elements by typing the name of the element you will like.
As for the reference field, be aware at the end your selection will be associated to a specific record of the table you're referencing. This could lead into confusion or issues either for your end users or your developers.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 01:16 AM
For reference and select box variables in Service Catalog, this can be achieved by ticking Unique values only checkbox in the variable definition. Strangely, there is no similar option for normal reference fields.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 06:31 AM
That is where GlideAggregate comes in handy. Always use it while getting distinct value.
Getting Distinct Records | GarrettNow
Distinct GlideRecord Query - ServiceNow Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2015 10:21 PM
Hey kalai
Its working in background scrips, but same way when i did with script include, its not working
its not returning any values at all.
I wrote the code like:
var ticket_id= [];
var ticket_list = new GlideAggregate('u_venn');
ticket_list.groupBy('u_ven_id);
ticket_list.query();
while(ticket_list.next())
{
ticket_id.push(ticket_list.sys_id+'');
}
if(ticket_id.length>0)
{
return 'sys_idIN'+ticket_id+'';
}
else
{
return 'sys_idIN'+'***'; //
}
BR
Nikh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2015 12:00 AM
Hi Nikh,
You may want to check if your script include is "client callable".
Thanks,
Berny