How to debug Client Callable Script Include when we call it in Report?

abhi710
Tera Contributor
 
16 REPLIES 16

jfuasid
Tera Contributor

The script would have to be client-callable to use in a report filter. gs.log does not work in client-callable scripts.

sushantmalsure
Mega Sage
Mega Sage

Hello Abhi710,

as you are calling script include you can always put gs.log() statements , also you can add 'Source' as 2nd parameter while adding the log that way you can filter the logs when you are looking at log table.

eg. gs.log('Calling from Report ','Abhi test');

Now you will be able to see the logs with source as 'Abhi test'.

Just reload/rerun the report after logs in place in script include and then check the logs table.

I can help you more if you can share screenshots of report with details on script include call and screenshot of script include which is getting called.

 

PS: make sure your script include is client callable as from report you can call client callable script includes.

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Hi Sushantmalsure,

Below is the Script Include, I am trying to call this in report. I am not even getting any logs in System logs. 

It is working in background Script but not in report. So, how to debug it?

 

var APM_reporting = Class.create();
APM_reporting.prototype = Object.extendsObject(AbstractAjaxProcessor, {

sampleFunction:function() {

// declare an aray
//gs.info('inside func');
gs.log("hello");
var sys_arr1 = [];
var dupRecords = [];
var duplicateCheck = new GlideAggregate('u_cmdb_ci_environment');
duplicateCheck.addNotNullQuery('u_gbl_apm_business_application');
duplicateCheck.addNotNullQuery('u_gbl_apm_provider');
duplicateCheck.addNotNullQuery('u_gbl_apm_type');
duplicateCheck.groupBy('u_gbl_apm_business_application');
duplicateCheck.groupBy('u_gbl_apm_provider');
duplicateCheck.groupBy('u_gbl_apm_type');
duplicateCheck.addHaving('COUNT', '>', 1); // addHaving func won't work in scope app
duplicateCheck.query();
while (duplicateCheck.next()) {
gs.log("entered@@@");
var jsonObj = {}; // declare a json object
jsonObj['u_gbl_apm_business_application'] = duplicateCheck['u_gbl_apm_business_application'].toString();
jsonObj['u_gbl_apm_provider'] = duplicateCheck['u_gbl_apm_provider'].toString();
jsonObj['u_gbl_apm_type'] = duplicateCheck['u_gbl_apm_type'].toString();
dupRecords.push(jsonObj);
}
gs.log("dupRecords"+dupRecords);
var jsonString = JSON.stringify(dupRecords); // convert json object to string
gs.log("jsonString"+jsonString);
var parser = new JSONParser();
var parsedData = parser.parse(jsonString);
var length = parsedData.length;

for (var i = 0; i < length; i++) {

var encodedQuery = 'u_gbl_apm_business_application' + '=' + parsedData[i]['u_gbl_apm_business_application'] + '^' + 'u_gbl_apm_provider' + '=' + parsedData[i]['u_gbl_apm_provider'] + '^' + 'u_gbl_apm_type' + '=' + parsedData[i]['u_gbl_apm_type'];
gs.log('codedQuery'+encodedQuery);
var tableRec = new GlideRecord('u_cmdb_ci_environment');
tableRec.addEncodedQuery(encodedQuery);
tableRec.query();
while (tableRec.next()) {
sys_arr1.push(tableRec.getUniqueValue());
}
}
// sys_arr1 = sys_arr1.toString();
//gs.log('sys_arr1' + sys_arr1);
gs.log("Lengfinal" + sys_arr1.length);
return sys_arr1;

},

 
 
 
 
 
 

 

 

 

can you please return 'return sys_arr1.join();' instead of 'return sys_arr1;' in script include ??

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Tried it getting same response.