Rahul Kumar17
Tera Guru

hi

 

i have checked ur code is correct run in background script

var dupRecords = []; 
 var gaDupCheck1 = new GlideAggregate('cmdb_ci_computer'); 
 gaDupCheck1.addQuery('active','true'); 
 gaDupCheck1.addAggregate('COUNT', 'serial_number'); 
 gaDupCheck1.groupBy('serial_number'); 
 gaDupCheck1.addHaving('COUNT', '>', 1); 
 gaDupCheck1.query(); 
 while (gaDupCheck1.next()) { 
 dupRecords.push(gaDupCheck1.serial_number.toString()); 
 } 
 gs.print(dupRecords);

 

it's giving the value 

56WHL71,AEX5635Z0001AC,L3BB911

only mistake this line

javascript : new script_include_name.method_name();

thanq
If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar

hi rahul,

pls check below and suggest if some thing wrong in calling script include

my script include as below,

function getDupes(){
var dupRecords = [];
var gaDupCheck1 = new GlideAggregate('cmdb_ci_computer');
gaDupCheck1.addQuery('active','true');
gaDupCheck1.addAggregate('COUNT', 'serial_number');
gaDupCheck1.groupBy('serial_number');
gaDupCheck1.addHaving('COUNT', '>', 1);
gaDupCheck1.query();
while (gaDupCheck1.next()) {
dupRecords.push(gaDupCheck1.serial_number.toString());
}
return dupRecords;
}

 

i given as below in report

javascript : new getDupes().dupRecords();

You only call the script include name and then the function name liek that if you've defined a class for your script inculde. Have a look at the link below, it explains the difference and how and when to use them.

https://community.servicenow.com/community?id=community_blog&sys_id=88bce625dbd0dbc01dcaf3231f9619be 

yes,

it's working fine

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar

hi,

it's working or not tell me

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar