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

This did not work. I'm still getting null sys ID.

HI @TerryC03 can you share your latest script include?

Regards
Harish

Sure.

var sprintUil = Class.create();
sprintUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
latestSprint: function(){
var sprintID;
var gr = new GlideRecord('sn_safe_sprint');
gr.setLimit(3);
gr.orderByDesc('sys_updated_on');
gr.query();

while(gr.next()){
sprintID = gr.sys_id;
gs.info(gr.getValue(sprintID));
}
return sprintID;
},
type: 'sprintUtil'
});

There's a warning in the log stating: "sprintUtil" is not defined ==>new sprintUtil().latestSprint()

Hi @TerryC03 here is the updated code. tested in background script

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

HarishKM_0-1709874304098.png

 

Regards
Harish

Should I remove everything else in the script include and just place this code there? I need to use the latest updated records for a report.