i,Dynamic filter with script include

Alon Grod
Tera Expert

Hi, 

Im trying to create a customize dynamic filter using script include that will show only groups that I belongs to without the parents group (the OOB One of my groups dynamic filter includes the parents group).

 

What am I doing wrong?

AlonGrod_0-1765973170141.png 

AlonGrod_1-1765973202207.png

var getMyGroupsOnly = Class.create();
getMyGroupsOnly.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getGroups: function(userId) {
		
		var cr = [];
        var gr = new GlideRecord('sys_user_grmember');
		gr.addQuery('user',userId);
		gr.addQuery('group.active',true);
		gr.query();
		while(gr.next()){
			var groupId = gr.getValue('group');
			if(!gs.nil((groupId))){
				cr.push(groupId);
			}
		}
        return cr;
    },

    type: 'getMyGroupsOnly'
});

 

 

Result:

AlonGrod_2-1765973250739.png

 

 

 

11 REPLIES 11

Anand2799
Tera Guru

Hi @Alon Grod ,

 

Select "Sandbox Enabled" checkbox in script include. The filter queries run in a sandbox enabled environment.

I was getting error logs as undefined. This fixed the issue.

 

Also, you don't need a Glide AJAX enabled script include.

 

Thanks

Anand

Bert_c1
Kilo Patron

Try:

 

javascript: new getMyGroupsOnly().getGroups();

for the Script field in the Dynamic filter definition.