The CreatorCon Call for Content is officially open! Get started here.

How to display the unique values through code

sasipriya
Tera Contributor

Hi Team,

 

Can anyone help me on below requirement.

 

I want to display the approver manager list, but in my code, I am getting the same manager three times. So, I wanted to eliminate those duplicate values through code, and I used the Glide record class.

 

Thanks,

Sasipriya.

 

1 REPLY 1

OlaN
Giga Sage
Giga Sage

Hi,

If you have the managers in an array, you can use the built in function to retrieve unique values.

Like so:

var fruits = ['banana', 'apple', 'orange', 'apple', 'banana', 'banana'];

var util = new global.ArrayUtil();
var uniqueFruits = util.unique(fruits);

gs.info('fruits: ' + fruits);
gs.info('unique values: ' + uniqueFruits);

// *** Script: fruits: banana,apple,orange,apple,banana,banana
// *** Script: unique values: orange,apple,banana