Skip to content

Instantly share code, notes, and snippets.

GlideRecord & GlideAggregate Cheat Sheet ❗

GlideRecord(String tableName) ❗

var gr = new GlideRecord('incident'); // use the incident table
gr.query(); // fetch data from the database
while (gr.next()) { // advance
    gs.info(gr.short_description);
}
@jgr1ffin
jgr1ffin / Add Variable Set.js
Created August 20, 2021 08:50 — forked from iamkalai/Add Variable Set.js
ServiceNow Snippets
(function () {
var getCatalog = new GlideRecord("sc_cat_item");
getCatalog.addEncodedQuery("active=true^hide_sp=false^sys_class_name=sc_cat_item"); //Update this
getCatalog.query();
while (getCatalog.next()) {
var addVariableSet = new GlideRecord("io_set_item");
addVariableSet.initialize();
addVariableSet.sc_cat_item = getCatalog.getValue("sys_id");
addVariableSet.variable_set = "86f3c8b51b0d9c508ed631d7dc4bcbcd"; //variable set sys_id