Rollback in GlideRecord

PhoenixMing0912
Giga Expert

Hi Experts:

I am using GlideRecord to update db tables.

I am wondering if rollback is possible after gr.insert() or gr.update()?

4 REPLIES 4

Harshad Wagh
Tera Guru

will you be using this in background script,

if yes, then you can refer below.

 

https://docs.servicenow.com/bundle/london-platform-administration/page/administer/table-administrati...

Thanks

Harshad

Not script background, glide update is used in a script include which is called in web api.

I am afraid , this is not possible, however if you wont be updating lot of fields then you can write create backup fields which will hold lasy value and can be used to revert.

 

Also,just wondering what is the use case?

if there is any  business logic to be checked before updating or inserting the data , we can write BRs for those cases for restrictions.

 

Thanks

Harshad

 

Service_RNow
Mega Sage

This might occur when there is a record in the [sys_rollback_context] which is left in the 'In progress' (in_progress) or 'Currently rolling back (reverting)' . This prevents the platform from executing any other rollback.

Run a script in the background script to change the state of the active record in sys_rollback_context table to Rolled back.

fixContextState();
function fixContextState() {
    var gr = new GlideRecord('sys_rollback_context');
    gr.get('___SYS_ID_OF_SYS_ROLLBACK_CONTEXT___');
    gr.state = 'recorded';
    gr.update();
}

Please Mark Correct if this had helped you.