Error: "org.mozilla.javascript.EcmaError: "GetGroupsOfTypeRefQual" is not defined." when using Script Include

Mitch Moses
Giga Expert

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'
};
1 ACCEPTED SOLUTION

vkachineni
Kilo Sage
Kilo Sage

Typo in

javascript:new GetGroupsOfTypeRefQual().getGroupsOfMyTypeQuery();

 

your script include is named GetGroupsOfTypeRefQaul

 

fix one of them.

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

View solution in original post

2 REPLIES 2

vkachineni
Kilo Sage
Kilo Sage

Typo in

javascript:new GetGroupsOfTypeRefQual().getGroupsOfMyTypeQuery();

 

your script include is named GetGroupsOfTypeRefQaul

 

fix one of them.

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Jaspal Singh
Mega Patron
Mega Patron

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.