- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 10:25 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2024 02:30 AM
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 as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2024 03:44 AM - edited 02-24-2024 03:45 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 10:37 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2024 01:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2024 02:30 AM
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 as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2024 03:44 AM - edited 02-24-2024 03:45 AM
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