Comments on: Distinct GlideRecord Query https://servicenowguru.com/scripting/gliderecord-distinct-query/ ServiceNow Consulting Scripting Administration Development Thu, 07 Mar 2024 16:51:18 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Kay https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8153 Thu, 15 Aug 2019 22:12:57 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8153 This was just what I was looking for, thanks for sharing.

]]>
By: Martijn https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8152 Thu, 03 Mar 2016 16:03:08 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8152 I believe gs.sql is discontinued in Geneva.

]]>
By: Debbie https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8151 Thu, 18 Dec 2014 12:50:33 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8151 Hi, I am trying to use this to create a LOV for a database column. I want to add Class to a change request. I want to create a select on the distinct classes used in cmdb_ci. I haven’t succeeded. Any suggestions would be greatly appreciated. thanks, /D

]]>
By: Mark Stanger https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8150 Wed, 30 Jul 2014 11:23:10 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8150 In reply to Joe Walters.

There might be a more efficient way, but a simple way would be to use my code above, but then add to a counter variable inside of the while loop instead of printing out the results. Right before the while loop you would initialize your counter variable at zero then right after the while loop you could print out your results.

]]>
By: Joe Walters https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8149 Wed, 30 Jul 2014 05:56:48 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8149 Hi Mark, adding on to this discussion, do you know of a way via script to then count how many distinct values there are? For instance, in your example above there are 9 distinct values for the OS. I have need to count the number of distinct values and have an idea of how to do it with a GlideRecord query, but for speed/efficiency, I’d prefer to do it with GlideAggregate (if possible).
Thanks!

]]>
By: Mark Stanger https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8148 Wed, 10 Jul 2013 18:39:38 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8148 In reply to Dennis.

I see what you’re saying. It’s a shame, but there is no such thing as a ‘NOTIN’ operator, or anything similar. I think what you’ll need to do is do several ‘!=’ operators with multiple ‘ANDs’ as separators. It will accomplish the same thing but will look a bit uglier. For this situation, you could probably just hide the filter completely and avoid the ugliness as well.

]]>
By: Dennis https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8147 Wed, 10 Jul 2013 18:33:55 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8147 In reply to Mark Stanger.

That got me a lot closer to what I’m after but I can’t seem to use a NOTIN filter on a list collector. It works just fine if I tell it to return all results where sys_idIN, that is, it shows me the groups of which I’m already a member. If I change that to sys_idNOTIN then the filter doesn’t show up on the list collector at all and it returns all results.

If I use the technique you described to push the groups of which I’m already a member to the right side, then how will the recipient of the catalog task know which groups I was already in and which I’m requesting now? I guess they could check themselves but that seems like extra effort.

]]>
By: Mark Stanger https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8146 Wed, 10 Jul 2013 14:59:31 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8146 In reply to Dennis.

I don’t think so. I think what you could do in that case would be to query for (and display) the groups that the user was already a member of and then move them to the right side of the slushbucket. That would leave the remainder in the left side. It’s not a simple scripting task, but could be done. Here’s a separate post I wrote that might get you started.

https://servicenowguru.com/scripting/client-scripts-scripting/move-list-collector-options/

Another option would be to set the filter of the list collector to filter out the groups that the user is already a member of, similar to a reference qualifier. You would need to query the sys_user_grmember table and then return a list of sys_id values of the groups the user already belonged to. Then you could set the list collector filter as shown here.

https://servicenowguru.com/scripting/client-scripts-scripting/changing-filter-list-collector-variable-client-script/

]]>
By: Dennis https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8145 Wed, 10 Jul 2013 14:19:12 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8145 Is there any way to use this functionality in a List Collector filter? I want to return a list of distinct options from the group member table that users can select (basically show me all groups of which I’m not already a member).

]]>
By: Mark Stanger https://servicenowguru.com/scripting/gliderecord-distinct-query/#comment-8144 Tue, 27 Mar 2012 21:27:40 +0000 https://servicenowguru.wpengine.com/?p=3289#comment-8144 In reply to Angela Doss.

Hey Angela, Welcome! I wrote a post to cover most of the common GlideRecord calls. It’s got examples of all of the common tasks. You can also ask on the ServiceNow forums for help.
https://servicenowguru.com/scripting/gliderecord-query-cheat-sheet/

]]>