Blog

ServiceNow Customer Background Scripts

Please note that this feature was deactivated in ServiceNow Helsinki.

Nearly every time I am using Background scripts, I glance at the bottom of the form and see "customer no scripts". Finally I did the research to find out how to use that feature.

Turns out that this is a place to store your frequently used background scripts. Let's check it out:

Picture of Customer Scripts

How use Customer Scripts.
Step 1: Create JS File

Create a .js text file to upload to ServiceNow. Here is an example file.

findDuplicates();
function findDuplicates() {
var dupRecords = [];
var gaDupCheck1 = new GlideAggregate('sys_user');
gaDupCheck1.addAggregate('COUNT', 'name');
gaDupCheck1.addNotNullQuery('name');
gaDupCheck1.addHaving('COUNT', '>', 1);
gaDupCheck1.query();
while (gaDupCheck1.next()) {
 var dup1 = gaDupCheck1.name;
 dupRecords.push(dup1.toString());
}
gs.print('Duplicate records found: '+dupRecords);
}

tep 2: Upload JS File

Step 3: Run File in Scripts - Background

File Running

File Results