- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 07:00 AM
I want to share this Glide Record with the community. I discovered this while experimenting with a Glide Record. I did not want to write multiple addorConditions so I came up with this. I have been testing arrays in Glide Records for about a month and it has always worked. My question is, how does the Glide Record loop through the array? Please feel free to try this yourself. It also works with !=, CONTAINS, DOES NOT CONTAIN .
var count = 0;
var REQs = ['5', '2', '3'];
var assnmGroup = ['Service Desk', 'Business Systems']
var gr = new GlideRecord('sc_request');
gr.addQuery('request_state', REQs);
gr.addQuery('assignment_group.name', assnmGroup);
gr.setLimit(130);
gr.query();
while (gr.next())
{
gs.log("number: " + gr.number);
gs.log("Request State: " + gr.request_state);
gs.log("Assignment Group: " + gr.assignment_group.name);
gs.log("Short Description: " + gr.short_description);
gs.log("*****************************");
count++;
}
gs.log("Count: " + count);
Snipped of the output.
*** Script: number: REQ0048208
*** Script: Request State: 3
*** Script: Assignment Group: Business Systems
*** Script: Short Description: UltiPro Time Base update
*** Script: *****************************
*** Script: number: REQ0048551
*** Script: Request State: 5
*** Script: Assignment Group: Business Systems
*** Script: Short Description: ODS Growth Curve: Add Modifiers
*** Script: *****************************
*** Script: number: REQ0048511
*** Script: Request State: 5
*** Script: Assignment Group: Business Systems
*** Script: Short Description: HS SharePoint Site
*** Script: *****************************
*** Script: number: REQ0048632
*** Script: Request State: 3
*** Script: Assignment Group: Business Systems
*** Script: Short Description: AcuTrak: DNA Sample Inv - Bulk Enter Samples - Add Current State to Results Grid
*** Script: *****************************
*** Script: number: REQ0048665
*** Script: Request State: 2
*** Script: Assignment Group: Service Desk
*** Script: Short Description: Global Protect VPN
*** Script: *****************************
*** Script: number: REQ0048660
*** Script: Request State: 5
*** Script: Assignment Group: Service Desk
*** Script: Short Description: Print from PigChamp
*** Script: *****************************
*** Script: number: REQ0028810
*** Script: Request State: 5
*** Script: Assignment Group: Service Desk
*** Script: Short Description: On-boarding Request
*** Script: *****************************
*** Script: number: REQ0048605
*** Script: Request State: 3
*** Script: Assignment Group: Service Desk
*** Script: Short Description: Quantity threshold breached: UPS Battery
*** Script: *****************************
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 01:23 AM
Cool, thanks for posting, i didn't know that addQuery would default to IN if you gave it an array. Please mark an answer correct to close the thread down.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 07:51 AM
*** Script: number: REQ0047933
*** Script: Request State: 2
*** Script: Assignment Group: Business Systems
*** Script: Short Description: Touch Base clocks offline > 7 days
*** Script: query: request_stateIN5,2,3^assignment_group.nameINService Desk,Business Systems
*** Script: *****************************
Used the != here.
*** Script: number: REQ0044551
*** Script: Request State: 7
*** Script: Assignment Group: Business Systems
*** Script: Short Description: Maximus
*** Script: query: request_state!=5,2,3^assignment_group.nameINService Desk,Business Systems
*** Script: *****************************
David, Thanks for showing me this query. Makes sense now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 07:56 AM
I'd recommend checking the results you're getting off the '!=' query. I was getting different results from that than i was with an 'IS NOT ONE OF' operator, not sure it's accurate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 07:58 AM
If you enter !=1,2 into the search bar in the state column of a list of incidents, the query it actually runs is:
stateIN1,2,3,6,7,8,9
No idea why but definitely isn't showing what you think it is in that query!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 08:12 AM
I will check the != again. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 08:57 AM
David,
Thanks for double check the script. The "!=" does not work. I used the "NOT IN" in the Glide Record and it seems to work. (Still testing). Ran the Glide Record (Background script) and got the same count as running the filer in the list view for requests. I check the first 50 records and the background script matches up with the list view query. This is way I finally posted this Glide Record wanted to get some more eyes on it to make sure the query works correctly.