Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Client Callable Script Include returning null

TerryC03
Tera Guru

Hello,

When I enter my script include into a report, the sysID is returning null.

TerryC03_0-1709854242270.png

What would be the reason for this? Below is my script include:

TerryC03_1-1709854359913.png

 

1 ACCEPTED SOLUTION

Hi @TerryC03 tested in my PDI, works fine now. Follow the below steps

1. Create a client callable script include like below

latestSprint: function(){
var sprintID;
var answer = []; // since you want more than 1 record use array to push values
var gr = new GlideRecord('sn_safe_sprint');
gr.setLimit(3);
gr.orderByDesc('sys_updated_on');
gr.query();

while(gr.next()){
answer.push(gr.getValue('sys_id'));
}

return answer.toString();
},
HarishKM_0-1709878525947.png

 

in your report use in condition like this

sysid ISONE OF javascript: new scriptincludename().latestSprint()

result:

HarishKM_2-1709878722145.png

 


 

 

Regards
Harish

View solution in original post

25 REPLIES 25

Hi @TerryC03 replace the below code to your function

latestSprint: function(){
var sprintID;
var answer = []; // since you want more than 1 record use array to push values
var gr = new GlideRecord('sn_safe_sprint');
gr.setLimit(3);
gr.orderByDesc('sys_updated_on');
gr.query();

while(gr.next()){
answer.push(gr.getValue('sys_id'));
}

sprintID = answer.join(',');
gs.info(sprintID);
return sprintID;
},

Regards
Harish

Ok. I did that and it did not work.

TerryC03_0-1709875254011.png

 

Hi @TerryC03 what did it print in logs? also what is your requirement?

Regards
Harish

My requirement is to create a report that calculates the average of the 3 latest completed sprints' completed points. I'm thinking to just populate three records at a time for the report.

 

The logs are still printing "sprintUtil" is not defined. 

TerryC03_0-1709875896807.png

Could the issue be how I'm calling the script? 

TerryC03_1-1709875955240.png

I'm also switching back and forth between client callable. Thank you for your help with this issue so far.

Hi @TerryC03 tested in my PDI, works fine now. Follow the below steps

1. Create a client callable script include like below

latestSprint: function(){
var sprintID;
var answer = []; // since you want more than 1 record use array to push values
var gr = new GlideRecord('sn_safe_sprint');
gr.setLimit(3);
gr.orderByDesc('sys_updated_on');
gr.query();

while(gr.next()){
answer.push(gr.getValue('sys_id'));
}

return answer.toString();
},
HarishKM_0-1709878525947.png

 

in your report use in condition like this

sysid ISONE OF javascript: new scriptincludename().latestSprint()

result:

HarishKM_2-1709878722145.png

 


 

 

Regards
Harish