
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 05-18-2022 09:31 AM
Dear all,
Thanks to a post from
They are defined pretty much like how we define our methods in the Script includes.
To explore do this:
<INSTANCE_URL>/scripts/js_includes.js
AND
<INSTANCE_URL>scripts/js_includes_sp.js
A great reference for developers who want to make some of their Util functions.
Examples:
setReadOnly: function(disabled) {
if (disabled) {
var unlockElement = gel(this.name + "_unlock");
lock(unlockElement, this.name, this.name + '_edit', this.name + '_nonedit', 'ni.' + this.name + '.select_1', this.name + '_nonedit');
hideObject(unlockElement);
} else if (gel(this.name + '_edit').style.display == "none") {
var unlockElement = gel(this.name + "_unlock");
if (isDoctype())
showObjectInlineBlock(unlockElement);
else
showObjectInline(unlockElement);
}
gel(this.name).disabled = disabled;
return true;
},
getValue: function() {
return this.select.options[this.select.selectedIndex].value;
},
addOptions: function(glideRecord, nameField, valueField) {
if (!valueField)
valueField = 'sys_id';
if (!nameField)
nameField = 'name';
while (glideRecord.next())
addOption(this.select, glideRecord[valueField], glideRecord[nameField]);
},
getClassName: function() {
return this.getWindowDOM().className;
},
// THE FAMOUS GETTER AND SETTER
getValue: function(fieldName) {
return this[fieldName];
},
setValue: function(fieldName, value) {
this[fieldName] = value;
},
And every time we set a query condition, this is what gets executed:
addQuery: function() {
var fName;
var fOper;
var fValue;
if (arguments.length == 2) {
fName = arguments[0];
fOper = '=';
fValue = arguments[1];
} else if (arguments.length == 3) {
fName = arguments[0];
fOper = arguments[1];
fValue = arguments[2];
}
this.conditions.push({ 'name' : fName, 'oper' : fOper, 'value' : fValue});
},
So, lovely to see the logics behind what we are using.
ServiceNow, loving it 🙂
Cheers,
Anish
- 1,185 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Anish, it is very helpful and gives us insights for our own Util functions, thank you for sharing this information with the Community!
Best regards,
Vivi Brasil

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
You are welcome!
Cheers,
Anish