Name
sn_uibtk_api.ScreenTestValue
Description
No description available
Script
const ScreenTestValue = Class.create();
ScreenTestValue.prototype = Object.extendsObject(BuilderToolkitAPIBase, {
TABLE: 'sys_uib_screen_test_values',
FIELDS: ['macroponent_config'],
/**
* @param fields {string[]}
*/
initialize: function(fields) {
BuilderToolkitAPIBase.prototype.initialize.call(this, this.TABLE, fields || this.FIELDS);
},
/**
* @param sysId {string} the ID of the record we want to get or the screen SysID we are related to
* @param shouldReturnGR {boolean} true if we are returning the GlideRecord vs. an object with values
*/
getRecordById: function(sysId, shouldReturnGR) {
try {
const recordGR = this.get(this.table, 'sys_id=' + sysId + "^ORscreen.sys_id=" + sysId, false, this.noDomain);
if (recordGR.next()) {
return shouldReturnGR ? recordGR : this.getValuesFromGlideRecord(recordGR);
}
} catch (err) {
gs.error(err);
}
return null;
},
/**
* @param fields {object} a object with keys in camel case and values
*/
updateRecord: function(screenId, {
sysId,
macroponentConfig
}) {
const stringifyMacConfig = this.stringifyJSON(macroponentConfig);
let screenTestValueGR = this.getRecordById(screenId ?? sysId, true);
if (screenTestValueGR && screenTestValueGR.canWrite()) {
screenTestValueGR.setValue('macroponent_config', stringifyMacConfig);
return screenTestValueGR.update();
}
screenTestValueGR = this.get(this.TABLE);
if (screenTestValueGR.canCreate() && screenId) {
screenTestValueGR.initialize();
screenTestValueGR.setValue('screen', screenId);
screenTestValueGR.setValue('macroponent_config', stringifyMacConfig);
return screenTestValueGR.insert();
}
return null;
},
type: 'ScreenTestValue'
});
Sys ID
c92085074572d11003e4310beeec175d