xplore scripts

#code #javascript #reference

Table of Contents

basic script

var count = 0;
var gr = new GlideRecord('incident');
gr.query();
while (gr.next()) {
    count++;
    gr.update();
}
gs.log('count: ' + count);
gr

Useful Commands

gr.deleteRecord();
gr.addQuery('active',false);
gr.addNotNullQuery('short_description');

Create a New Record

gr.initialize();
gr.insert();

Count Records in a Query

var gr = new GlideRecord('elements');
gr.addQuery('hierarchy', 'sys_id');
gr.query();
gs.log('Incident count: ' + gr.getRowCount());
gr