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.
Fixes issues when using "Track in Update Sets" UI action on custom scoped app table.
/**
* 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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment