Name

global.NomenclatureUtils

Description

this utlils can be used to do and undo nomenclature changes...

Script

var NomenclatureUtils = Class.create();
NomenclatureUtils.prototype = {
  initialize: function() {},
  applyOrRollbackNomenclature: function(scopes) {

      if (scopes) {
          var propertyValue = this._getNomenclatureProperty();
          var arr = this._getLabels();

          if (propertyValue != null && propertyValue == "false") {

              for (var i = 0; i < arr.length; i++) {
                  var nameObject = arr[i];
                  this._updateLabels(nameObject, "sys_documentation", scopes, "label", "plural", "hint");
                  this._updateLabels(nameObject, "pa_tabs", scopes, "name");
                  this._updateLabels(nameObject, "sys_app_module", scopes, "title", "hint", "mobile_title");
                  this._updateLabels(nameObject, "pa_widgets", scopes, "name", "description", "lookup_name");
                  this._updateLabels(nameObject, "pa_breakdowns", scopes, "name", "description");
                  this._updateLabels(nameObject, "pa_indicators", scopes, "name", "description");
                  this._updateLabels(nameObject, "pa_cubes", scopes, "name", "description");
                  this._updateLabels(nameObject, "pa_dashboards", scopes, "name");
                  this._updateLabels(nameObject, "pa_dimensions", scopes, "name", "description");

                  this._updateLabels(nameObject, "sys_gauge", scopes, "name", "title");
                  this._updateLabels(nameObject, "sys_report", scopes, "title", "y_axis_title", "x_axis_title", "chart_title", "description");
                  this._updateLabels(nameObject, "sys_ui_list_control", scopes, "label");
                  this._updateLabels(nameObject, "sys_ui_action", scopes, "hint", "name");

                  this._updateLabels(nameObject, "sys_ui_view", scopes, "title");
                  this._updateLabels(nameObject, "item_option_new", scopes, "question_text");
                  this._updateLabels(nameObject, "sys_wizard_answer", scopes, "name");
                  this._updateLabels(nameObject, "sys_ui_hp_publisher", scopes, "name");

                  this._updateLabels(nameObject, "sys_sg_form_screen", scopes, "name");
                  this._updateLabels(nameObject, "sys_sg_list_screen", scopes, "name");
  				
  				this._updateLabels(nameObject, "sn_grc_asmt_group_options", scopes, "name");
                  //this.updateLabels(nameObject,"sys_relationship",true,"name");
                  //this.updateLabels(nameObject,"sys_collection",false,"label");
              }

              if (arr != null && arr.length > 0) {
                  this._updatePortalLabels();
                  this._updateAnnotationInAudit();
              }

              var gr = new GlideRecord('sys_properties');
              gr.get('name', 'sn_grc.enable_nomenclature_labels');
              gr.setValue('value', true);
              gr.update();
  			
          } else if (propertyValue != null && propertyValue == "true") {
              // this else block still need to be executed as part of upgrade process to support pre NY to O 
              for (var j = 0; j < arr.length; j++) {
                  var translation = arr[j];
                  this._updateLabels(translation, "sys_report", scopes, "title", "y_axis_title", "x_axis_title", "chart_title", "description");
              }

              this._updatePortalLabels();
          }

          //this._syncDictionaryLabels(scopes);
      }

  },

  _updateAnnotationInAudit: function() {

      var gr = new GlideRecord('sys_ui_annotation');
      if (gr.get('e43f846cd7011200d77c83e80e61031c')) {
          gr.setValue('text', 'Add Entities to this Engagement. Select Validate to complete scoping.');
          gr.update();
      }
  },

  _syncDictionaryLabels: function(scopes) {

      var dictionary = new GlideRecord('sys_dictionary');
      dictionary.addQuery("sys_scope", "IN", scopes);
      dictionary.addQuery('internal_type', '!=', 'collection');
      dictionary.setWorkflow(false);
      dictionary.query();

      while (dictionary.next()) {

          var documentation = new GlideRecord('sys_documentation');
          documentation.addQuery('name', dictionary.name);
          documentation.addQuery('element', dictionary.element);
          documentation.query();

          if (documentation.next() && dictionary.column_label != documentation.label) {
              dictionary.column_label = documentation.label;
              dictionary.update();

          }

      }


  },

  _getNomenclatureProperty: function() {
      var gr = new GlideRecord('sys_properties');
      gr.get('name', 'sn_grc.enable_nomenclature_labels');
      return gr.getValue('value');
  },

  _updateLabels: function() {

      var nameObject = arguments[0];
      var temp = nameObject.labels;
      var table = arguments[1];
      var scopes = arguments[2];
      var query = "";

      for (var i = 3; i < arguments.length; i++) {
          query = query.concat(arguments[i] + "LIKE" + nameObject.name + "^OR");
          if (nameObject.plural)
              query = query.concat(arguments[i] + "LIKE" + nameObject.plural + "^OR");
      }

      query = query.slice(0, -3);

      var metadataTable = new GlideRecord(table);
      metadataTable.addEncodedQuery(query);
      metadataTable.addQuery("sys_scope", "IN", scopes);
      metadataTable.query();

      while (metadataTable.next()) {

          var sysUpdateName = metadataTable.sys_update_name;
          var customerUpdate = new GlideRecord("sys_update_xml");
          customerUpdate.addQuery("name", sysUpdateName);
          customerUpdate.query();
          if (customerUpdate.getRowCount() == 0) {

              for (var j = 3; j < arguments.length; j++) {
                  var columnValue = metadataTable.getValue(arguments[j]);

                  if (columnValue) {
                      for (var key in temp) {
                          if (columnValue.indexOf(key) != -1) {
                              var reg = new RegExp(key, 'g');
                              columnValue = columnValue.replace(reg, temp[key]);
                              metadataTable.setValue(arguments[j], columnValue);
                          }
                      }
                  }
              }
              metadataTable.update();
          }
      }
  },
  _getLabels: function() {
      var data = [];
      var obj = {};
      var labels = {};
      obj.name = "Profile";
      labels["profiles"] = "entities";
      labels["Profiles"] = "Entities";
      labels["profile"] = "entity";
      labels["Profile"] = "Entity";


      obj.labels = labels;
      data.push(obj);

      obj = {};
      labels = {};
      obj.name = "Policy Statement";
      labels["policy statement"] = "control objective";
      labels["Policy statement"] = "Control objective";
      labels["Policy Statement"] = "Control Objective";


      obj.labels = labels;
      data.push(obj);

      return data;
  },
  _getPortalLabels: function() {
      var labels = {};

      labels["Exempted Controls by Profile"] = "Exempted Controls by Entity";
      labels["Profiles by Engagement"] = "Entities by Engagement";
      labels["Profile"] = "Entity";
      labels["My Profiles"] = "My Entities";
      labels["Non Compliant Profiles"] = "Non Compliant Entities";
      labels["Policy Exceptions by Profile"] = "Policy Exceptions by Entity";
      labels["Total Policy Statements by Policy"] = "Total Control Objectives by Policy";
      labels["Policy Exceptions by Policy Statements"] = "Policy Exceptions by Control Objectives";

      return labels;
  },
  _updatePortalLabels: function(needNomenclature) {

      var labels = this._getPortalLabels(needNomenclature);

      for (var key in labels) {
          var gr = new GlideRecord('sys_portal_preferences');
          gr.addQuery('portal_section', 'IN', [
              //sys_portal_preferences sys_ids: comments: <dropzone>, <summary>, <page>
              '08546b8c9f02030030581471367fcf8c', // dropzone999, , Policy Overview
              '88546b8c9f02030030581471367fcf92', // dropzone999, , Policy Overview
              'aca871aec3201300ba8adb1122d3ae33', // dropzone999, , Policy Overview - PA Premium
              'e0a871aec3201300ba8adb1122d3ae49', // dropzone999, , Policy Overview - PA Premium
              '1fcf7db6cb300200829cf865734c9c63', // dropzone0, , Risk Overview
              '38a3e38c9f02030030581471367fcfb3', // dropzone1, , Audit Engagement Overview
              '9b1e2bc49f42030030581471367fcf22', // dropzone3, , Audit Engagement Overview - Premium
              '3444e78c9f02030030581471367fcf6b', // dropzone999, , Compliance Overview
              '22d0bb089f42030030581471367fcf48', // dropzone3, Compliance Overview - PA Premium
              'ead0bb089f42030030581471367fcf59', // dropzone999, Compliance Overview - PA Premium
              '9992300f531003003b638e56a11c0874', // -, Policy Exceptions by Profile, Policy Exception Overview
              '69e3bc0f531003003b638e56a11c0801', // -, Policy Exceptions by Control Objective, Policy Exception Overview
              '04b9c4819f02030030581471367fcf86', // -, Entity, PA Residual Risk Reports - Premium
              'b1280c419f02030030581471367fcf39', // -, Entity, PA Inherent Risk Reports - Premium 
              '725fcc08db93af003101b12c4e9619b6', // -, Baseline Common Controls by profile, PA Policy Statements
              'a65fcc08db93af003101b12c4e9619a6', // -, Baseline Compensating Controls by Profile, PA Policy Statements
              'c80f4bfcdb5f23404b97fb371d961934', // -, Baseline compliance profiles summary, PA New Tab
              '265fcc08db93af003101b12c4e961986', // -, Baseline Supplemental Controls by Profile, PA Policy Statements
              '43f2dda3dbf227003101b12c4e9619e4', // -,Profiles compliance overview, PA New Tab
              '78930fc0db5baf003101b12c4e9619fa', // -, Profile Effectiveness, PA Monitor --
              'ff0938f0db1b23404b97fb371d9619a4', // -, Risk Assessments by Profile, PA New Tab --
              '734255a3dbf227003101b12c4e961943', // -, Active control attestations by Profile, PA Assess --
              'de79fcf0db1b23404b97fb371d961954', // -, Ineffective Profiles, PA New Tab --
              '694ab834db1b23404b97fb371d9619a9', // -, Profile Effectiveness, PA New Tab --
              '265fcc08db93af003101b12c4e961986', // -, Baseline Supplemental Controls by Profile, PA Policy Statements --
              '725fcc08db93af003101b12c4e9619b6', // -, Baseline Common Controls by Profile, PA Policy Statements --
              'a65fcc08db93af003101b12c4e9619a6', // -, Baseline Compensating Controls by Profile, PA Policy Statements --
              'b25fcc08db93af003101b12c4e9619b9', // -, Compensating controls by profile, PA Policy Statements --
              'ba5fcc08db93af003101b12c4e9619bf', // -, Common controls by profile, PA Policy Statements --
              'ea5fcc08db93af003101b12c4e96193d', // -, Supplementing controls by profile, PA Policy Statements --
              'fa5fcc08db93af003101b12c4e9619c2', // -, Assurance controls by profile, PA Policy Statements --
              '1588623edb0beb003101b12c4e96195b', // -, # of Ineffectiveness Profiles, PA Monitor --
              'a42656fedbc7eb003101b12c4e96191e', // -, Profile Effectiveness, PA Monitor --
              '53a8b605db1f23403101b12c4e9619f4', // -, Risk Assessments by Profile - DNA, PA Monitor --
              '55fc7dbadb87eb003101b12c4e961940', // -, Target Missing Profiles, PA Authorize --
              '9c0be478db9fef003101b12c4e9619d3', // -, Profiles With Completed Impacts and No Baseline Controls-DNA, PA Authorize --
              '5093cbc0db5baf003101b12c4e961975', // -, Target Missing Profiles, PA Authorize --
              '2306b070dbdfef003101b12c4e96192e', // -, All NIST Policy Statements -DNA, PA Select --
              '801f4c60db57ef003101b12c4e96198d', // -, Baseline Policy Statements - DNA, PA Select --
              'a68783c4db5baf003101b12c4e96191c', // -, DNA - All NIST Policy Statements, PA Select --
              'bc8703c4db5baf003101b12c4e9619d8', // -, DNA - All Baseline Policy Statements, PA Select --
              '566a01bcdb1b23404b97fb371d961914', // -, Recommended Baseline Compensating Policy Statements, PA New Tab --
              '6ab9497cdb1b23404b97fb371d96199f', // -, Recommended Baseline Assurance Policy Statements, PA New Tab --
              '957a81bcdb1b23404b97fb371d961924', // -, Recommended Baseline Supplemental Policy Statements, PA New Tab --
              'e86a01bcdb1b23404b97fb371d961971', // -, Recommended Baseline Common Policy Statements, PA New Tab --
              '665fcc08db93af003101b12c4e9619a3', // -, Baseline Supplemental Policy Statements, PA Policy Statements --
              '6e5fcc08db93af003101b12c4e96199c', // -, Baseline Assurance Policy Statements, PA Policy Statements --
              'd6809c48db93af003101b12c4e9619dc', // -, Recommended Baseline Assurance Policy Statements - Copy, PA Policy Statements --
              'e25fcc08db93af003101b12c4e961983', // -, Baseline Common Policy Statements, PA Policy Statements --
              'e25fcc08db93af003101b12c4e961990', // -, All Recommended Baseline Policy Statements, PA Policy Statements --
              'e65fcc08db93af003101b12c4e9619a9', // -, Baseline Compensating Policy Statements, PA Policy Statements --
              '469d5e36db0beb003101b12c4e9619e8', // -, All NIST Policy Statements, PA Select --
              '4bbc1636db0beb003101b12c4e96193c', // -, All Baseline Policy Statements, PA Select --
              '09653392db1723004b97fb371d96194c' // -, Profiles compliance overview, PA New Tab
          ]);
          gr.addQuery('value', key);
          gr.query();
          gr.setValue('value', labels[key]);
          gr.updateMultiple();

      }

  },
  type: 'NomenclatureUtils'
};

Sys ID

e86cbbd073232300b472d11ee2f6a7de

Offical Documentation

Official Docs: