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

MrMuhammad
Giga Sage

Hi,

You can leverage Table API and make a get request by passing the sys_id of user to the task table. That will return you the tickets information in response. Give it a try in REST API Explorer.

Table API Refrence  

https://developer.servicenow.com/dev.do#!/reference/api/orlando/rest/c_TableAPI#r_TableAPI-GETid

Rest Explorer API -https://docs.servicenow.com/bundle/orlando-application-development/page/integrate/inbound-rest/conce...

Let me know if you have any questions

Thanks & Regards,

Sharjeel

Regards,
Muhammad

Kieran Anson
Kilo Patron

Hi,

will this just be tasks that extend the task table or other tables? If the latter, it would be easier to create a scripted rest api.

Example using REST API Explorer

GET https://xxx.service-now.com/api/now/table/task?sysparm_query=assigned_to.user_id%3Dadmin

Hi Kieran,

Yeah it will be task and its extended tables. Is there a sample code for the scripted REST API that gets the count of tickets from the table when the assigned_to value is given as input.

For this you can use the Aggregate API to return a count of records based on a query string.

find_real_file.png

GET https://xxx.service-now.com/api/now/stats/task?sysparm_query=assigned_to.user_id%3Dadmin&sysparm_count=true&sysparm_group_by=assigned_to