Skip to content

Force Local Updates into an Update Set through a Background Script

Viewing 1 post (of 1 total)
  • Author
  • #6652

    One of the great things about the ServiceNow platform is the ability package up any number of configuration changes into a localized named set called an Update Set. This helps migrate any local changes from your instance onto another for testing and deployment purposes.

    Typically when an Update Set is created, it gives you the option to make it your current Update Set. Then, any component that is added/updated in your instance will get reflected into said set. However, many times we may not be aware that our changes are not going to the correct place or perhaps we created the Update Set after some changes had been made on the instance that you were planning to group together. In most (if not all) of our SIAM integrations, Update Sets are key components for easier deployment to your QA and Production environments.

    If you’ve run into any of these scenarios before, there’s a way to get your updates moved to the desired Update Set. This script can be run in the background and will force update your records.

    Pre-Requisite: The Update Set where you’re moving these records to is your Current one.
    Switch isSingleRecord to false if you’re moving a list of records (say, if you’re moving all the PSP Field Maps for your Incident to Common Incident Table map)

    var table_name = “TABLE_NAME”;
    var record_sys_id “REPLACE_ME”;
    var isSingleRecord = true;
    var cur = new GlideRecord(table_name);
    cur.addQuery('sys_id', record_sys_id);
    // you can add more custom query conditions here
    if (isSingleRecord) {;
         // Commit any changes to the record
    } else {
          while ( {
              // Commit any changes to the record
    //Check to make sure the table isn't synchronized already
    var tbl = cur.getTableName();
    //Push the update into the current update set
    var um = new GlideUpdateManager2();
    //Query for the current update set to display info message
    var setID = gs.getPreference('sys_update_set');
    var us = new GlideRecord('sys_update_set');
    //Display info message and reload the form'Record(s) included in current update set.');
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.