Restore a field value from the audit history table

David Casper
Tera Guru

I've ran into some CI records which name field was updated to the generic asset name which now makes no sense. After reviewing the sys_history_line table i verified that the old name value is correct. My goal is to update the CI record name to this old name value. 

Has anyone done this before? I've only spent a few minutes on it so far, but i'm trying to determine how I can tie the CI record to the sys_history_line table together so I can update the name field through a script. Just wanted to post this before the end of the day to see if someone has ran into this before and might save me some time. 

Thanks as always!

4 REPLIES 4

sachin_namjoshi
Kilo Patron
Kilo Patron

sys_history_line is part of table rotation which happens every 7 days.

So, querying sys_history_line won't help you since this table is rotated every 7 days.

Also, you may get performance issues if you query sys_audit, sys_history_line table due to huge number of records.

 

Instead, i will suggest you to load renamed CI data using data sources, transform maps.

Building spreadsheet with renamed CI will be little painful but this will be one time.

 

Regards,

Sachin

That's what I'm trying to avoid LOL. Also we don't have data for all that. 

I didn't know about the rotation, very good info. My backup is to pull what I can from a sub instance. It won't be all records I'm sure, but probably a lot if not most. 

It just stinks being able to see the data I want and not access it. 🙂 

Sven Bauer
Tera Contributor

You could query sys_audit, as this is the source of data shown insys_history_line.

Query should be something like

'sys_created_on ', <date or range of renaming>

'tablename', <your speicific CI table>

'fieldname', 'name'

'documentkey', <sys_id of your CI reocrd>

'newvalue', <Asset Tag>

 

The old Value is stored in "oldvalue" and you could get the data from there

G24
Kilo Sage

@Sven Bauer that was helpful.  Thank you.

I made several invalid updates to some tables, and I was hoping to use the sys_audit table to find the last known good value, and restore the records.

However, when I search the table, it seems like I only see the BAD values (boxed in red, below).  The history does not seem to go back far enough to include the good data that I'm looking for, even though my updates were only a couple of days ago.  Why would that be?  Any ideas?

find_real_file.png