Name

sn_uibtk_api.UIBTemplate

Description

No description available

Script

var UIBTemplate = Class.create();
UIBTemplate.prototype = Object.extendsObject(BuilderToolkitAPIBase, {
  TABLE: 'sys_uib_template',
  FIELDS: ['label', 'description', 'macroponent', 'image', 'associated_types', 'optional_properties', 'required_properties', 'macroponent_config'],

  /**
   * @param fields {string[]}
   */
  initialize: function(fields) {
      BuilderToolkitAPIBase.prototype.initialize.call(this, this.TABLE, fields || this.FIELDS);
  },

  /**
   * Overrides parent class function to inject special fields
   * @param acc {object} the accumulator object
   * @param field {GlideElement} the field element we are currently working on
   */
  getFieldValues: function(acc, field) {
      acc = BuilderToolkitAPIBase.prototype.getFieldValues.call(this, acc, field);
      const fieldName = field.getName();
      if (fieldName === 'associated_types') {
          acc['associatedTypes'] = field.getDisplayValue();
      } else if (fieldName === 'macroponent') {
          acc['layout'] = this.parseJSON(field.layout.toString(), {
              sysId: acc.sysId,
              field: 'layout'
          });
      } else if (fieldName === 'image') {
          acc['image'] = field.getDisplayValue();
      }
      return acc;
  },

  getTestValues: function(acc, {
      name,
      testValue = null,
      generator = null
  }) {
      acc[name] = testValue;
      if (generator !== null) {
          const segments = generator.split(':');
          switch (segments[0]) {
              case 'gr':
                  if (segments.length !== 1) {
                      const recordLookup = new GlideRecord(segments[1]);
                      recordLookup.addQuery('active', 'true');
                      recordLookup.query();
                      if (recordLookup.next()) {
                          acc[name] = recordLookup.getUniqueValue();
                      }
                  }
                  break;
              case 'javascript':
                  if (segments.length !== 1) {
                      //TODO
                      //Uncomment this once global script include has been updated

                      //OTHER NOTES
                      // This was the only way I was able to evaluate a script
                      // without creating a new table and inserting a record everytime
                      // the script was run

                      //acc[name] = this.evaluateScript(segments[1]);
                  }
                  break;
          }
      }
      return acc;
  },

  type: 'UIBTemplate'
});

Sys ID

23dd674421531110da6a9589bbcb02f2

Offical Documentation

Official Docs: