Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

22 REPLIES 22

Have you marked your script include as client callable? That box must be ticked to be called in a report condition. 

You don't need the class, you can call it as you were, script include should look like below:

find_real_file.png

hi david, still i am getting 0 records in report

please find script include as below, this is client callable 

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;
}

find_real_file.png

please find report as below,

javascript : new getDupes().dupRecords();

find_real_file.png

hi

don't use client callable 

u pass the 

javascript : new script_include_name.method_name();

 

thanq

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

Thanks,
Rahul Kumar

Confirm your script include is named getDupes and call it as you were: 

javascript: getDupes()

this works on my PDI:

script include:

find_real_file.png

Report:

find_real_file.png

Deepthi, please confirm you've configured this as above. If you have it should now be working so please mark my answer correct to close the thread down.