How to I add a query parameter of Assignment Group to Scripted REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 10:32 AM
Hello All, I have a scripted API with query parameter searches for record count and date range of Incident records. I would like to add a query parameter for "Assignment Group" to the script. I have included the assigngroup in the "Query Parameter Associations"
var assigngroup = "",
if(request.queryParams.assigngroup != "" && request.queryParams.assigngroup != null) {
assigngroup = new GlideRecord(request.queryParams.assigngroup);
gr.addQuery( 'inc_assignment_group.getDisplayValue()', '==', assigngroup );
}
If a group is entered "GROUP A"
The API returns records for all groups, does not filter by the assigngroup. If I remove ".getDisplayValue":
Response Body
{ "results": [] }
How can I get the assigngroup to filter the results?
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 11:19 AM
HI,
Script is not proper:
gr.addQuery( 'inc_assignment_group.getDisplayValue()', '==', assigngroup ); : This will not work as you have inc_assignment_group.getDisplayValue in this.
Use below one:
gr.addQuery( 'inc_assignment_group.name', '==', assigngroup.toString());
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 11:24 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 11:51 AM
Hello,
If your query parameter is assigngroup then you can reference it as such in your query (Also few changes made to your query as it was not correct):
var assigngroup = request.queryParams.assigngroup,
if(assigngroup != "" && assigngroup != null) {
var gr = new GlideRecord('incident');
gr.addQuery( 'assignment_group.name', assigngroup );
gr.query();
while(gr.next()){
///DO something with returned Incidents matching assignment group
}
}
Hope this helps.
--David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 12:16 PM
Thank you for the reply David. Your script did not work. The results are all Incident regardless of Assignment group when the Assigned Group is add to the Query Parameters:
Here is additional information on my script"
var assigngroup = "",
table = 'api_view',
gr = new GlideRecord(table);