Skip to content

Instantly share code, notes, and snippets.

@ChecksumFailed
Last active March 22, 2024 15:34
Show Gist options
  • Save ChecksumFailed/13f88aaaadf218c36c13e87cd387b268 to your computer and use it in GitHub Desktop.
Save ChecksumFailed/13f88aaaadf218c36c13e87cd387b268 to your computer and use it in GitHub Desktop.
Just some random things
/**
* Creates a new GlideRecord Object from inputs, calls query(), then retuns the Object
* @private
* @param {object} options - Object containing table and any gliderecord methods to call
* @returns {GlideRecord}
* @example
* var options = {
* "table": "cmdbi_ci_computer",
* "methods": {
* "addEncodedQuery": "active=true",
* "setLimit": 1,
* "query":null
* }
* }
* glideRecordHelper()
*/
_glideRecordHelper: function(options) {
if (!options || !options.hasOwnProperty("table") || !options.hasOwnProperty("methods")) {
throw "Invalid arguments. Example: <add example>"
}
var grRecord = new GlideRecord(options.table);
var objMethods = options.methods;
for (var fn in objMethods) {
if (typeof grRecord[fn] === "function") {
grRecord[fn](objMethods[fn]);
}
}
return grRecord;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment