Issue while retrieving records from sys_history_line using Rest API

Prakash10
Giga Contributor

Hi All,

Problem here is, am unable to see records for the sys_history_line table while using in REST API. For some incidents it shows records and for some it is not showing any records.

Request URL: https://<instance>.service-now.com/sys_history_line.do?JSONv2&sysparm_query=set.id=<sys_id>

Method: GET & Status code: 200 Ok

Response:

{
"records": [

]
}

Any help for the above problem is much appreciated. Thank you.

1 ACCEPTED SOLUTION

Prakash10
Giga Contributor

Hi Sanjiv,

Thank you so much for your help. Got a fix for the issue to access the historical ticket data especially to get Work Notes updated time, Ticket assigned time, Ticket On-hold time, Ticket Resume time.

Service-Now Table: sys_audit_list

sysparm query: documentkey (value is the sys id of the INC ticket)

SAMPLE API:

https://<INSTANCE>.service-now.com/sys_audit_list.do?JSONv2&sysparm_query=documentkey=<SYS ID OF THE TICKET>";

NOTE:

ADMIN ACCESS ALONG WITH THE UI ACCESS IS MANDATORY TO ACCESS THE ABOVE TABLE.

View solution in original post

16 REPLIES 16

The sys_history_line table is archived every 7 days and those archived data are stored in the archived table as I have shown you in above screenshot.

 

So if you are receiving a blank response for a record, you will have to send the rest api to the archived tables sys_history_line0001,sys_history_line0002 etc


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,

Still having the same problem, just got full access to the service-now account from my admin team. However still finding empty data while accessing sys_history_line, sys_history_line0000, 0001, 0002 & 0003.

 

What can be done to fix the above issue? [This issue is only there while fetching old data, am able to fetch for any recent service-now Incident]

 

Where exactly I can find the ticket on-hold time, ticket resume time and ticket assigned time from one desk to another desk and work notes entry.

The incident_metric table can give you the onhold time and then assigned time etc. Infact you can use that for stuff you wanted to pull from History table. Such as, whom it was assigned to, state changes etc


Please mark this response as correct or helpful if it assisted you with your question.

Thanks for the quick response Sanjiv. Will you be able to provide more details on the "Incident_metric" table, what all those that I can use for the sys_param_query to fetch the required data.

Will you be able to provide me some sample please?

Is there any other way to find the response for the sys_history_line table? 

SanjivMeher
Kilo Patron
Kilo Patron

It is definitely tough to get the old data from history table.

I would suggest start collecting the everyday so that, you don't have to pull the old data which are weeks old. And you will have to convince your client, thats not feasible, and I can only pull recent last 7 days data.

 

Next regarding metric, you can use below end point

 

https://<instance>.service-now.com/api/now/table/metric_instance?sysparm_query=mi_definition%3D35f2b283c0a808ae000b7132cd0a4f55%5Einc_incident_state%3D3&sysparm_limit=1


Please mark this response as correct or helpful if it assisted you with your question.