Skip to content

Instantly share code, notes, and snippets.

@jmaxwell81
Forked from johncaruso/fixTrackInUpdateSets.js
Created January 20, 2019 05:35
Show Gist options
  • Save jmaxwell81/bbe5d25f908b16372270a96cd24fda21 to your computer and use it in GitHub Desktop.
Save jmaxwell81/bbe5d25f908b16372270a96cd24fda21 to your computer and use it in GitHub Desktop.

Revisions

  1. @johncaruso johncaruso created this gist Oct 15, 2018.
    36 changes: 36 additions & 0 deletions fixTrackInUpdateSets.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    /**
    * Fixes issues when using "Track in Update Sets" UI action on custom scoped app table.
    *
    * Per https://community.servicenow.com/community?id=community_question&sys_id=760fb629db58dbc01dcaf3231f9619bd
    * a temporary table with a prefix of rep$x_ may be added to your app scope.
    *
    * As of Kingston, table columns get created in app scope but the table does not.
    *
    * @param {string} tableName
    */
    function fixTrackInUpdateSets(tableName) {

    /**
    * Move table with prefix rep$x_ to global scope (if added to scoped app)
    */

    // var grTable = new GlideRecord('sys_db_object');
    // grTable.get('8efd12900f904300abfedb0be1050ef7');
    // grTable.sys_scope = 'global';
    // grTable.update();

    /**
    * Move rep$x_ table's columns to global scope
    */

    var grField = new GlideRecord('sys_dictionary');
    grField.addQuery('name', tableName);
    grField.query();

    while (grField.next()) {
    grField.sys_scope = 'global';
    grField.update();
    }
    }

    // fixTrackInUpdateSets('rep$x_cita2_iq_connection');