- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
How many times has it happen to you that you write a background script and loose it for one of the following reasons:
|
Worry no more as that script is not lost and you can get it back from the sys_script_execution_history table
Not only this you can also Rollback any* changes done by this script
Lets look at an example: Run this in a background script
var testGR = new GlideRecord('incident');
testGR.get('25b66ea12f0b7550fb09ad2ef699b6bc'); //use sys_id of incident on your instance
testGR.state= 2;
testGR.work_notes = 'This is for SN community blog';
testGR.update();
Check the result Result:
Now Lets see how can you recover the script if you lost it
From the menu -> Now Navigate to Rollback & Recovery -> Script Execution History (sys_script_execution_history)
Useful Data in Table : This table holds the scripts executed and you can come here to recover the script if you lost it or closed the window or something.
Not just this you can also see
- Who ran the script
- Start and end time
PS: This table is flushed every 7 days so you won't get data older than that.
Drilling in, you can get more info on the SQL Count, SQL Time and Also the Processing & Response times (in milliseconds)
- SQL Count: Total SQL Commands executed
- SQL Time: Time Taken by SQL Commands in Milliseconds
- Transaction Processing Time: This is the processing time of the transaction, and this does not include the time taken waiting for a worker
- Response Time: Response Time in Milliseconds
Furthermore, you can see the number of tables where the data was inserted/updated. Directly or indirectly. For the example we have we just update the work notes and state but here you can see that form the backend there are 5 tables where data is inserted/updated.
Now let’s Rollback this script.
To Rollback the same form has a little related link as shown below
Clicking on the same gives confirmation to proceed.
Enter 'yes' and proceed.
Validating results
- I went back to the incident and saw that the state was reverted to original state
- It still shows the journal entry that state was updated, but no journal entry for state revering.
- The work notes entered are still present on the Incident and it is not reverted.
Summary
- This is a handy place to recover the background script, which I often loose.
- Good to rollback changes on records.
- This can rollback some basis changes not very efficient as it cannot rollback journals or emails triggered etc.
- 1,133 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.