How to revert a record to original values?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2022 09:06 AM
Hi,
I've a requirement where I want to revert all the fields in an incident record to the original value. The original value whcih it had while insertion.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2022 09:50 AM
How do you want to do it, do you want it to happen for all the records or want a one time action for record of user's choosing?
Depending on the scenario you will need to create a Fixed script or scheduled job, and for 2nd scenario you can build up a UI action, so user can restore value for a particular record.
The solution will work by looking at "sys_audit" table
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2022 11:16 AM
This is an example which I tried out:
var gr = new GlideRecord('incident');
gr.addQuery('sys_id','13c8955587945550cfdd2f49cebb3554');
gr.query();
if(gr.next())
{
var audit = new GlideRecord('sys_audit');
audit.addQuery('documentkey','13c8955587945550cfdd2f49cebb3554');
audit.query();
if(audit.next())
{
for(var i = 0;i<audit.getRowCount();i++)
{
gr[audit.fieldname] = audit.oldvalue;
}
gr.update();
}
}
I know the placement of gr.update() in the above script should be inside for loop. But I want the update on the target record at once, not separately
How can I achieve it?