Client Callable Script Include returning null

TerryC03
Tera Expert

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 so you want to show based on safe team? in that case you need to check safe team value in script include to filter results based on team

Regards
Harish

Hello,

The initial question worked. I'll try to look for help for a dynamic filter option for the interactive filter. Thank you for all of your help!

Parth_Poriya
Tera Expert

Hi

 

The reason because your sprintID variable is initalization to undefined and you are returning nothing that's the reason it is returning null 

May you give an example of how to return the number of the record. This is what I now have:

var sprintUtil = 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 = push(gr.getValue('number'));
}
return sprintID;
},
type: 'sprintUtil'
});

Sandeep Rajput
Tera Patron
Tera Patron

@TerryC03 Could you please confirm in which scope this script include is created (Global or some other application scope). 

 

Also, the reference field from where you are calling the script include, does it belong to the same scope in which the script include is created or it belongs to a different scope?