
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2019 11:38 AM
I think I have done something wrong setting up this code. Can anyone point out the mistake?
The Error in the system logs
org.mozilla.javascript.EcmaError: "GetGroupsOfTypeRefQual" is not defined.
Caused by error in <refname> at line 1
==> 1: new GetGroupsOfTypeRefQual().getGroupsOfMyTypeQuery();
The reference qualifier in assignment group dictionary
javascript:new GetGroupsOfTypeRefQual().getGroupsOfMyTypeQuery();
The script Include
var GetGroupsOfTypeRefQaul = Class.create();
GetGroupsOfTypeRefQaul.prototype = {
initialize: function() {
},
getGroupsOfMyTypeQuery: function() {
var myGroups = this.getMyGroups();
var myGroupsTypes = this.getGroupTypesOfGroups(myGroups);
var groupsOfMyTypes = this.getGroupsOfType(myGroupsTypes);
var encQry = 'sys_idIN' + groupsOfMyTypes.join(",");
return encQry;
},
getMyGroups: function() {
var usr = gs.getUser();
var javaGroupsArray = usr.getMyGroups(); // Returns Java array, need to convert to JS array
var jsGroupsArray = javaGroupsArray.toArray();
var groupsStr = jsGroupsArray.join(",");
return groupsStr;
},
getGroupTypesOfGroups: function(groups) {
var groupTypes = [];
var gaUserGroup = new GlideAggregate('sys_user_group');
gaUserGroup.addAggregate('COUNT', 'type');
gaUserGroup.addQuery('sys_id','IN',groups);
gaUserGroup.query();
while (gaUserGroup.next()) {
groupTypes.push(gaUserGroup.getValue('type'));
}
return groupTypes;
},
getGroupsOfType: function (groupTypes) {
var groups = [];
var grGroups = new GlideRecord('sys_user_group');
grGroups.addQuery('type','IN',groupTypes);
grGroups.query();
while(grGroups.next()) {
groups.push(grGroups.getValue('sys_id'));
}
return groups;
},
type: 'GetGroupsOfTypeRefQaul'
};
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2019 11:58 AM
Typo in
javascript:new GetGroupsOfTypeRefQual().getGroupsOfMyTypeQuery();
your script include is named GetGroupsOfTypeRefQaul
fix one of them.
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2019 11:58 AM
Typo in
javascript:new GetGroupsOfTypeRefQual().getGroupsOfMyTypeQuery();
your script include is named GetGroupsOfTypeRefQaul
fix one of them.
Vinod Kumar Kachineni
Community Rising Star 2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2019 12:03 PM
Hi Mitch,
There is a spell error in name of Script include being passed in the javascript part of the code. Also, make sure you have Client Callable checkbox checked.
Thanks,
Jaspal Singh
Hit Helpful or Correct onthe impact of response.