- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hello Team,
I have below code which brings records which has duplicate Users. [licenseRec.user]
How can I make this into store only unique User records?
Currently both of my array length is coming out same. [i.e. icenseRec & arrayUnq ]
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
try this
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi @Sunny14 ,
As I can see the output of script is different it shows record count on query is 9811, and when applied unique arrayUtil is printing 1, means it is working. It might be the issue with your query
I have tried with below it is working. see below
var arr=["bh","md","kj","bh","ew","md","kj","we","we"];
arr=new global.ArrayUtil().unique(arr)
gs.info("Array Length: "+arr.length+", New Array: "+arr)
and the Output is
*** Script: Array Length: 5, New Array: bh,ew,md,kj,we
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hello @Bhimashankar H
Thank you for your response. Yes, this is working fine as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Script I provided was to remove duplicate elements from Array. Check your while loop as I believe there is a mismatch in data type.
Below is the sample for unique array,
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago