Restore Archived Record using script in ServiceNow

Vamsi Krishna10
Tera Contributor

Dear Community,

 

How to restore a archived record using scripting in ServiceNow? I didn't find any dedicated documentation related to restore archive records API's. 

 

Tried: new GlideArchiveRestore().restore(object.sys_id); but no luck.

 

Please, let me know if we have any alternate API's which are working.

 

 

1 ACCEPTED SOLUTION

Weird
Mega Sage

I'd imagine GlideArchiveRestore would work, since it's what the Restore record ui action uses.
What does your object contain?
The actual UI action on the archive table restores the record based on the sys_archive_log record, so you'd have to make sure you're using that sys_id and not the one from the archive table.

So,
new GlideArchiveRestore().restore(current.sys_id);
Current in current.sys_id is in sys_archive_log table
Make sure you're not using sys_id from "ar_sc_request" for example.



View solution in original post

6 REPLIES 6

Weird
Mega Sage

I'd imagine GlideArchiveRestore would work, since it's what the Restore record ui action uses.
What does your object contain?
The actual UI action on the archive table restores the record based on the sys_archive_log record, so you'd have to make sure you're using that sys_id and not the one from the archive table.

So,
new GlideArchiveRestore().restore(current.sys_id);
Current in current.sys_id is in sys_archive_log table
Make sure you're not using sys_id from "ar_sc_request" for example.



Hi Joni,

 

Will it work for scoped application as well?

Probably if you add global to the call -> new global.GlideArchiveRestore().restore(current.sys_id);
You might need to add some cross scope priviledges if there are none yet.

SatyakiBose
Mega Sage

Hello @Vamsi Krishna10 

May I know the use case for restoring archived data using script?