can we generate sys_history_line with a script

Ravish Shetty
Tera Guru

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.

1 ACCEPTED SOLUTION

Matthew Billy
Tera Expert

Hey @Ravish Shetty,

 

There is way to generate the sys_history_line via GlideHistorySet. You can execute it as given below

new GlideHistorySet(<table name>, <record.sys_id>).generate()

e.g.

new GlideHistorySet("task", task.sys_id).generate();

 

Original answer was here: Querying sys_history_line 

 

I hope you find this helpful, please mark if so.

 

View solution in original post

4 REPLIES 4

Gangadhar Ravi
Giga Sage
Giga Sage

@Ravish Shetty  please check below and see if helpful.

 

https://www.servicenow.com/community/developer-forum/records-not-inserted-in-sys-history-line-table/...

 

Please mark my answer correct and helpful if this works for you.

thanks Gangadhar. this is the exact problem that I am facing but it did not seem like the person got an answer for their query or maybe it is not possible

Matthew Billy
Tera Expert

Hey @Ravish Shetty,

 

There is way to generate the sys_history_line via GlideHistorySet. You can execute it as given below

new GlideHistorySet(<table name>, <record.sys_id>).generate()

e.g.

new GlideHistorySet("task", task.sys_id).generate();

 

Original answer was here: Querying sys_history_line 

 

I hope you find this helpful, please mark if so.

 

simonsparke
Tera Contributor

If you are finding that you are missing the latest sys_history_line records, after you generate using GlideHistorySet there is another function:

new GlideHistorySet(<table name>, <record.sys_id>).refresh()

Which can be used to retrieve/generate the latest sys_history_line's for an existing set.

Hope this helps anyone who stumbles upon this thread