How to regenerate the Audit Entries in the sys_history_line table from the sys_audit table?

srirampappagudi
Tera Expert

Hi Experts,

As per the below tutorials, the sys_history_line table drops off history records older than 28 days.... How can these records be regenerated from the audit table?

The system limits History Set and History records by:

  • Having the table cleaner delete History Set records that have not been updated in 30 days.
  • Using Table Rotation to rotate between four History tables every seven days. This means the system drops History records that are older than 28 days.

Should someone need historical information again at a later date, the system can regenerate it from auditing source records.

Kindly check and help.

Regards,

Sriram.

3 REPLIES 3

michaelskae
ServiceNow Employee
ServiceNow Employee

Hi Sriram,



If there is no History Set for a particular record, the system will create one.


If no-one has viewed a record for 28 days, then no history set is required.



You can manually create a new History Set by right-click on the record header, then select History > List. This will access the audit history of the record and generate the data.



Mike


is there a way we could create the history set using a script instead of manually creating it by opening a record.

context: we are trying to retrieve a data from thousands of user profiles and we are querying the history set tables but we saw that not all records have history sets because of which our query does not find anything.

srimech2000
Tera Contributor

I am also having this exact issue. Is it possible to create the history set via a background script?

If I physically open the target record (sc_req_item in my case), then the sys_history_set and sys_history_line records are getting recreated and my script is able to fetch the data.