- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 12:12 AM
i tried in following way but when i RUN report 0 records where displaying, when i run same script in background script i am getting desired out put after printing. Please suggest.
please find my screen shot and script as below
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 01:38 AM
Just to reiterate: you only call scriptIncludeName().methodName() if you have defined a class for your script include. Deepthi, you have written a classless script include so you need to call it as you were:
javascript: getDupes()
To confirm, you definitely need to have the client callable box ticked in order to call this in a report condition.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 01:01 AM
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
Thanks,
Rahul Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 01:07 AM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 01:12 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 01:26 AM
yes,
it's working fine
Thanks,
Rahul Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2019 01:38 AM
hi,
it's working or not tell me
Thanks,
Rahul Kumar