Records not inserted in sys_history_line table

deepak50
Tera Contributor

Hi,

I have written a logic in script include to check how many times a field of Case updated. For this I am querying sys_history_line table with case set id.

The records are inserted in this table for case when case is created manually using case form. But records are not  inserted in this table when cases are created using GlideRecord Script.

Is there any reason why Records not inserted in sys_history_line table while created through script and how can we fix this issue.

 

Thanks

Deepak

2 ACCEPTED SOLUTIONS

James Chun
Kilo Patron

Hi @deepak50,

 

Refer to the documentation for the details - https://docs.servicenow.com/bundle/washingtondc-platform-security/page/administer/security/concept/c...

 

Long story short, History Set [sys_history_line] is generated when a user creates or views the history of a record (e.g. right-click the header menu and select History > List).

Also, it's worth noting that the History Set record will be deleted when not used after x number of days and will be recreated when someone views the history again.

 

With your requirement, you won't be able to use the History Set table as it's highly likely that the data won't be available and of course, you can't use the Audit [sys_audit] table as well.

 

Does your record have a field that tracks the total number of updates?

What is your use case for this?

 

Thanks

View solution in original post

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

James is spot on. For what you are describing, sys_history_line is by far not the right go to. This table is only populated with records from when someone manually views the history of specific records (and so also not the updates after this).

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

7 REPLIES 7

AshishKM
Kilo Patron
Kilo Patron

Hi @deepak50 , 

Please check the GlideRecord code creating cases, for any system level method used as false, like setWorkflow(false);

 

-Thanks,
AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi Ashish,

I tried this on my pdi also and found the same issue. Not sure if this is default functionality of servicenow.

 

Thanks

Deepak

James Chun
Kilo Patron

Hi @deepak50,

 

Refer to the documentation for the details - https://docs.servicenow.com/bundle/washingtondc-platform-security/page/administer/security/concept/c...

 

Long story short, History Set [sys_history_line] is generated when a user creates or views the history of a record (e.g. right-click the header menu and select History > List).

Also, it's worth noting that the History Set record will be deleted when not used after x number of days and will be recreated when someone views the history again.

 

With your requirement, you won't be able to use the History Set table as it's highly likely that the data won't be available and of course, you can't use the Audit [sys_audit] table as well.

 

Does your record have a field that tracks the total number of updates?

What is your use case for this?

 

Thanks

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

James is spot on. For what you are describing, sys_history_line is by far not the right go to. This table is only populated with records from when someone manually views the history of specific records (and so also not the updates after this).

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn