OBLYTECH Logo
OBLYTECH Logo

Rolling Back a ServiceNow Fix Script Safely After an Update

A ServiceNow fix script runs on first install or once an update adds it, so a later update does not undo it. Reversing one safely depends on three checks: whether the script was saved with the Record for rollback option, whether the rollback window is still open, and whether the change altered the schema in a way that blocks rollback. Check all three first.

What an update does to a fix script

Fix scripts run during the first installation of an application, and again when an application is updated after the fix script has been added to it. A fix script that was already present does not run again on later updates. That behaviour is what makes a fix script feel permanent, and it is also why a rollback question comes up after an update: the script has already done its work, and any later version of the application will not re-run it. For the wider picture around an upgrade, see troubleshooting upgrades and release readiness.

Anyone with the admin role can run a fix script by hand. The route is All, then System Definition, then Fix Scripts. Filter the list on the application name, open the record, and select Run Fix Script. The same record carries the settings that decide whether the run can be reversed later, so read them before you change anything. If update sets are new to you, start with the update set explainer.

The fields that decide whether a run can be reversed

A fix script record holds a small set of fields. Each one affects how the script behaves and what it leaves behind.

Field What it controls
Unloadable Creates Customer Update records (sys_update_xml) when the script runs
Before Runs the script before the application is installed or upgraded, rather than after
Record for rollback Records the execution of the script so that it can be reverted if needed

The Record for rollback field is the one that matters for this topic. The field description says it records the run so it can be reverted. A script saved without that option gives you no recorded run to reverse, so the first question to ask about an old fix script is whether that box was ticked when it was written. Open the record and check before you plan anything else.

The Before field is worth a look too. A script set to run before the upgrade has a different starting state from one that runs after it, so a rollback plan has to start from the state the instance was in before that run, not from the state after the update.

How long a rollback stays available

Rollback contexts are the records that hold the data needed to reverse a change. By default they are kept for 10 days. A scheduled job named Clean Expired Rollback Contexts runs daily and deletes the expired ones. After that point the context is gone, and the change it held cannot be reversed through rollback.

The window is longer for some sources. Applications installed from the ServiceNow Store have 15 days to roll back by default, controlled by the property glide.rollback.expiration_days_app_install. Contexts that get stuck are kept for an extra 30 days beyond the normal expiry, controlled by glide.rollback.stuck_expiration_days.

Property names follow a pattern. They start with glide.rollback.expiration_days_ and end with a suffix that matches the Type value on the rollback context record. You add or change them in the System Properties table. Names differ between releases, so check the exact spelling on your own instance before you rely on it.

The practical reading is simple. Count the days from the update, not from the day you noticed the problem. If the window has closed, rollback is no longer an option and the fix has to be handled another way. For how release timing is planned around upgrades, see the release versions explainer.

Changes that stop a rollback context from being created during a rollback

Some schema changes stop a rollback context from being created when they run during a rollback itself.

  • Dropping a table or a column. Dropping an index is still allowed.
  • Truncating a table.
  • Renaming a table or a column.
  • Re-parenting a table or promoting a column.
  • Changing the type of a column.
  • Decreasing the width of a column.

This list matters most when a fix script touched structure as well as data. Review the script for any of these operations before assuming a rollback will restore the earlier state. A script that inserted, updated or deleted records without touching structure is the simpler case for a rollback.

Which databases support rollback

The rollback and delete recovery features work on MySQL and MariaDB. Oracle instances get rollback only. SQL Server instances get neither rollback nor delete recovery. If your instance runs on SQL Server, a fix script rollback is not a route you can plan around, and the recovery method has to be a backup or a corrective script.

The database platform sets the options before anything else does. An instance on MySQL or MariaDB can plan around both routes, while an instance on SQL Server has to plan around a different recovery route from the start.

Recovering deleted records

A fix script that deleted records raises a separate question from a fix script that changed field values. The delete recovery route has its own window. Cascaded deletions must be recovered within seven days of the deletion. Plan for that window separately from the 10-day rollback window. The Script Execution History module tracks background script runs for seven days.

The delete recovery windows are seven days, shorter than the 10-day rollback default. A deletion found on day eight can therefore sit inside one window and outside the other, so compare the two windows against the date of the deletion itself.

A safe order of work

Work through these steps in order before reversing anything.

  1. Confirm the instance type. Rollback is typically performed on pre-production instances, where the functionality has to be restored. On production, a rollback needs more care, because it deletes data and can make the root cause harder to find.
  2. Confirm the date. Work out how many days have passed since the update and compare it with the 10-day default or the longer window that applies to your source.
  3. Read the fix script record. Check the Record for rollback field and the Before field.
  4. Review the script for schema changes from the list above.
  5. Check the database platform.
  6. Before rolling back any rollback context, write down what the rollback will remove. A rollback deletes data, and that can make the root cause harder to find once the evidence is gone.

If any of these checks fails, the rollback is not the right tool. A corrective fix script, applied as a new change, is usually the safer route. It leaves a visible record of what was done, and it does not depend on a window that may already have closed. For the change side of that step, see change and release management. If update sets are part of the problem, troubleshooting update sets and release management covers that case.

Frequently asked questions

Does an application update run a fix script again?

No. A fix script runs at first installation and when an update is applied after the script has been added. A fix script that already exists does not run again on later updates. To run one again, an admin has to start it manually from the Fix Scripts list.

What does the Record for rollback option do?

It records the execution of the script so that the change can be reverted if needed. A script saved without this option does not give you a recorded run to reverse.

How long do I have to roll back a change?

By default, 10 days. Applications installed from the ServiceNow Store have 15 days by default. The window can be extended with system properties, and stuck contexts are kept for an extra 30 days.

Which changes stop a rollback context being created during a rollback?

Dropping a table or column, truncating a table, renaming a table or column, re-parenting or promoting a column, changing a column’s type, and decreasing a column’s width. Dropping an index is still allowed.

Which databases support rollback?

MySQL and MariaDB support both rollback and delete recovery. Oracle supports rollback. SQL Server supports neither rollback nor delete recovery.

Should I roll back on a production instance?

Rollback is typically used on pre-production instances. On production, treat a rollback as a deliberate decision and write down what it will remove before starting it.