Need to call script include in reporting.

Pragati4
Tera Contributor

Hi All

I have a requirement in which i want to get report of all the cases who's assignment group is part of "report group".

"report group" is a field which i have created in my user form in which we can add n number of groups.

 I know we can achieve this using script include then calling that function using java script but that is knot working i dont know why.

i have written below code but this is not working

var getGroup = Class.create();
getGroup.prototype = {
initialize: function() {
},
getreportgroup: function(){
var group ='';
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',current.sys_id);
user.query();
while(user.next()){
group = user.u_report_group.toString();
}
group = 'sys_idIN' + group;
gs.log('testing'+ group);
return group;

},
type: 'getGroup'
};

11 REPLIES 11

hi,

Please declare the group variable as "var group=[]" an in the while statement write the below code :

while(user.next()){
group.push(user.u_report_group.toString());
}

and return the groups like as "return 'sys_idIN' + group"

Thanks

Community Alums
Not applicable

The "report_group" is a field of "sys_user" table?

If yes, you can try this:

Objective: Display the number of cases by assignment group (member of report_group field)

Filter for the report

assignment_group javascript:getReportGroup()

Find ArrayUtil Script Include and set to Client Callable

Script Include: ArrayUtil
Client Callable: true

Add getReportGroup Script Include

Script Include: getReportGroup
Client Callable: true
Description: Returns all report groups of your current user

function getReportGroup(){
//Set Variables
var myUserObject = gs.getUser();
var myReportGroup = "";
var arrayUtil = new ArrayUtil();

var myrpGR = new GlideRecord(sys_user);
myrpGR.addQuery("sys_id","IN",getUserID());
myrpGR.query();
while(myrpGR.next()){
	myReportGroup.push(myrpGR.u_report_group.sys_id.toString());
}
return arrayUtil.unique(myReportGroup);
}