Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Getting activity log of specific incident through the REST API

mahadevanswamy
Kilo Explorer

I would like to know how to get the activity log of a specific incident through the REST API. I have looked at a similar post in this forums and it didn't help me out. I am using Service NOW Helsinki. Please let me know the table name by which I can get the activity logs of a specific incident.

Thanks in advance,

Swamy

19 REPLIES 19

I got the sys_id of the incident


find_real_file.png



after getting the sys_id and querying it in the sys_history_line table, I am not getting anything.


find_real_file.png


A little more research showed me that the set field is not a document_id, but a reference to the sys_history_set record, which has the document_id to the record you want. Sorry about that.



You can see this by entering sys_history_set.list in the navigation filter.


I don't have access to view that information on the sys_history_set table. Is there any other way to get activity logs by incident id?


The only way I see is to get information from sys_history_line which reference sys_history_set, which references the incident record. Without access to those tables, I don't see any other recourse other than to write your own logging mechanism.


Your query on sys_history_line would be set.document_id=<sys_id>



However, this will only work if someone has recently viewed the record in the system.   History Sets/Lines are a cached version of the history of the ticket that gets refreshed based off someone actually accessing the record in the UI.   After a period of time this cache is removed.   The data in the history set is a combination of records from the sys_audit, sys_journal_field, sys_email tables at least (I'm not sure how it generates relationship added/remove entries, they might be in sys_audit also.



What is your specific requirement?   You say the activity log, but are you looking for the changes to specific fields, or everything?