calling script include in report

Deepthi13
Tera Expert

 

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

 

1 ACCEPTED SOLUTION

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.

View solution in original post

20 REPLIES 20

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

please refer to the following threads, you will find useful information for achieve it:

https://community.servicenow.com/community?id=community_question&sys_id=54e043a5db98dbc01dcaf3231f96...

https://community.servicenow.com/community?id=community_question&sys_id=5c7043e1db98dbc01dcaf3231f96...

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

hi alberto, i have seen that links and followed same way, but i need to modify script include probably can u check once script include

function getDupes(){
var dupRecords = [];
var gaDupCheck1 = new GlideAggregate('cmdb_ci');
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;
}

The code seems okay, you have to change the condition in the report:

javascript: new ScriptIncludeName().getDupes();

Please try this.

Cheers

Alberto

Hi alberto ,

 

yes i changed to  (  javascript: new getDupes().dupRecords(); )

but still facing same and i am getting 0 records, pls suggest

 

I want to get duplicate serial number cmdb_ci_computer records in report