- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 02:58 AM
How to get a list of unique values of a field of a partiular table
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 03:34 AM
Hi Surya,
Something like this would do it. I would recommend caution when running queries on task as the table can be very large and could cause performance issues.
var gr = new GlideAggregate("task");
gr.addAggregate("COUNT");
gr.groupBy("cmdb_ci");
gr.query();
while (gr.next()) {
gs.print(gr.getAggregate("COUNT") + " -- " + gr.getValue("cmdb_ci") + " -- " + gr.getDisplayValue("cmdb_ci"));
}
Does this help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 03:21 AM
Hi Surya,
Can you elaborate?
Thanks,
Kaka Nayeem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 03:22 AM
Hello Surya,
You can use GlideAggregate to do so.
I can give you a hand if you give more a little more info on the table structure.
Thanks,
Cameron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 03:24 AM
I want to get a list of unique CI which are used in task table.
Since a single CI has been used in many task records, i want to get a list of unique Ci used there
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 03:28 AM
Yes you can use GlideAggregate. and use groupBy on CI field.
Search for "GlideAggregate" in wiki to get more details.