Need to get the unique values for a reference field

Yesh
Tera Contributor

Hi Team,

My reference field is visible like this:

IM Argentina Operating Unit

IM Argentina Operating Unit

IM Argentina Operating Unit

IM Argentina Operating Unit

IM BR OU

IM BR OU

.............

But I need the unique Values.

How to achieve this requirement?

Thanks,

Yesh

1 ACCEPTED SOLUTION

Nikhil65
Mega Guru

Hi @yesh ,

Why don't you get all sysid into an array, then use unique of arrayUtil class.

Then you can populate the select box with the unique values of array.

Api | ArrayUtil - ServiceNow Developers

 

Hope this helps!

 

Thanks,

Nikhil

View solution in original post

11 REPLIES 11

Tudor
Tera Guru

Hello Yesh,

 

Please try:

field = current.getValue(field_name);

As opposed to getDisplayValue - this will return the sys_id of the reference field.

Hope this helps!

 Tudor

Yesh
Tera Contributor

Hi Tudor,

I want the field Values only and these should be unique. I don't want sysID.

Thanks,

Yesh

_ChrisHelming
Tera Guru

Go to the sys_db_object table, find your table, and set the field you want displayed as the display field.

Hi Chris,

I have already set the display field. Here I need the unique values of that field. Do you have suggestion for this?

Thanks,

Yesh