REST API - Get the Input of user id and Pass the count of Assigned Tickets

Hari7
Kilo Guru

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. 

15 REPLIES 15

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.

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

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. 

Your original request was for "assigned_to" as in the Assigned To field from task table or are you wanting caller/ requested for etc?

 

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

 

Yes my original request is for getting count of tickets assigned to an user but I also need to get similar type Ike count of tickets submitted by an user (input will be the user name. For ritm it will be request. requested_for, for incident it will be caller, for hr case - opened for etc). If we get the assigned to working I thought the logic would be the same for others but the external team is looking for a one single API which can do everything. I have no clue on how to achieve this. Please let me know if you have done something like this.