Need to call script include in reporting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2019 02:53 AM
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'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2019 03:12 AM
Hi Pragati,
You should send an array, updated script here
var group =[];
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',current.sys_id);
user.query();
while(user.next()){
group.push(user.u_report_group.toString());
}
gs.log('testing'+ group);
return 'sys_idIN' + group;
},
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2019 03:22 AM
In report i m calling this function as:
assignment group is javascript:new getGroup().getreportgroup();
but getting all the ticket detail in which assignment group is empty.
I do not know what is wrong in this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2019 03:29 AM
Hi Pragati,
current object won't work here. I believe what you want is groups based on logged in user so use gs.getUserID()
Updated code:
user.addQuery('sys_id',gs.getUserID());
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2019 03:35 AM
Hi Ankur
Thankyou for your response.
This is also not working its giving me all the record in which assignment group is empty.
script:
var getGroup = Class.create();
getGroup.prototype = {
initialize: function() {
},
getreportgroup: function(){
var group =[];
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',gs.getUserID());
user.query();
while(user.next()){
group.push(user.u_report_group.toString());
}
gs.log('testing'+ group);
return 'sys_idIN' + group;
},
type: 'getGroup'
};
Regards,
Pragati