Rest API to get the incidents assigned to a user in last month?

Kiddy
Tera Guru

Hi

I want to sent all incidents assigned  to a user in last 30 days ,i cant see assigned to date field

on incident so that i can filter the date can you please suggest how to sent this information

we were provided by the userid by the requester and in response need to send the incidents assigned to him in this month

thanks

 

 

1 ACCEPTED SOLUTION

Hi @Kiddy ,

 

along with ID number, it is not possible to get short description and state of incident. In the end of endpoint URL, i have done the dot walk to get incident number from ID, same way you can get short description by giving like this id.short_description but that will not give response along with number.

 

 

View solution in original post

9 REPLIES 9

Hi,

for that you will have to query the sys_history_line table and check the history of incident

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Harika Bhupathi
Giga Guru

Hi @Kiddy 

 

We don't have any specified field in incident , which will track the assigned dates. In fact you can use metric_instance table where we have metrics defined for Incident table assigned_to field, which will basically capture the duration of assigned_to field for a particular user.

You can use below Table API to get the list of incidents which were assigned_to a particular user for last 30 days.

 

https://YOURINSTANCENAME.service-now.com/api/now/table/metric_instance?sysparm_query=table%3Dincident%5Efield%3Dassigned_to%5Esys_created_onRELATIVELT@dayofweek@ahead@30%5Evalue%3DBushra%20Akhtar&sysparm_fields=id.number

 

Here is the output , how I have achieved

1.From the instance, you need to first get the proper filter which records you want to send from metric_instance table.

 

Below I'm getting list of incidents assigned to Bushra Akhtar for last 30 days

find_real_file.png

 

Now you need to give the end point URL and user credentials in reqbin.com, which is open application to test the API's.

You can see the output on right side response

 

find_real_file.png

 

 

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

 

Regards,

Harika

@Kiddy ,

for assigned date you can refer start field in metrics table, for end date you can refer end field value

Hi Harika,

 

Thanks for the solution i tried its returning the id number ,

i need to get the short description and state of the incident in the response as well is this achievable ??

Hi @Kiddy ,

 

along with ID number, it is not possible to get short description and state of incident. In the end of endpoint URL, i have done the dot walk to get incident number from ID, same way you can get short description by giving like this id.short_description but that will not give response along with number.