REST API - Get the Input of user id and Pass the count of Assigned Tickets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2020 07:23 AM
I have a requirement where I need to get the value of the user id as input outside of ServiceNow and send this value to ServiceNow using REST API to get the count of how many tickets assigned to this user id. Please let me know if anyone has done something like this or have some inputs.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2020 01:58 PM
Hi Kieran,
I have tried this approach earlier before posting this question in Community. The link what i have used is
https://xxxxx.service-now.com/api/now/stats/sc_req_item?sysparm_query=active%3Dtrue%5Erequest.requested_forDYNAMIC90d1921e5f510100a9ad2572f2b477fe&sysparm_count=true
Here Dynamic followed by sys id relates to Dynamic is Me but the requirement here is instead of defining it to "ME" or logged in user, they want to pass the value of the Assigned To and get the count of the tickets.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2020 02:35 PM
Hi Hari,
If you have already tried a solution, you should say that in your first post to save community responders wasting time offering solutions you have already tried.
To make it simple, what do you mean by "value" what value are they passing? UserID, first name, date of birth...please be specific.
https://xxxxx.service-now.com/api/now/stats/sc_req_item?sysparm_query=active%3Dtrue%5Erequest.requested_for.user_name%3Djohn.turner&sysparm_count=true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2020 02:42 PM
Hi Kieran,
User id is the value that will be passed from outside of ServiceNow (SN) and that should return the count of total number of tickets assigned to that user id given as input.
In your recent link, you have given the requested for for RITM whereas for incident it is Caller.
How to get this count as one single API which does all the above activities.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2020 03:37 PM
Your original request was for "assigned_to" as in the Assigned To field from task table or are you wanting caller/ requested for etc?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2020 03:44 PM
GET https://xxx.service-now.com/api/now/stats/task?sysparm_query=assigned_to.user_id%3Djohn.turner&sysparm_count=true&sysparm_group_by=assigned_to