Rollback in GlideRecord
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2020 11:20 PM
Hi Experts:
I am using GlideRecord to update db tables.
I am wondering if rollback is possible after gr.insert() or gr.update()?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2020 11:27 PM
will you be using this in background script,
if yes, then you can refer below.
Thanks
Harshad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2020 12:20 AM
Not script background, glide update is used in a script include which is called in web api.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2020 01:02 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2020 11:33 PM
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.