Limit assignment group selection based on user's group + one exception

JohnDF
Mega Sage

Hi everyone,

 

I need help with a advanced reference qualifier. 

If logged in user belong to a group which name start with "SN-CC" then he should see only his groups he belongs to + the one exception group with sys_id xyz.

 

All other logged in user which not belongs to a group which name start with "SN-CC" then he should see all assingment groups.

Thanks for help!

1 ACCEPTED SOLUTION

Hello @JohnDF ,

 

Does this resolved your issue?? If yes, Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.

 

Regards,

Siddhesh

View solution in original post

16 REPLIES 16

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @JohnDF ,

 

I have tested below script please try and let me know.

 

 

 

 

 

var GroupFilter = Class.create();
GroupFilter.prototype = {
    initialize: function() {
    },

	
filterGroups: function() {
var user = gs.getUserID();
groupIds = [];
var groupFilter = '';
	var gr = new GlideRecord('sys_user_grmember');
	gr.addEncodedQuery('user='+ user +'^group.nameSTARTSWITHSN-CC');
	gr.query();
	while(gr.next()){
groupIds.push(gr.group.sys_id);
	}

if (groupIds.length > 0) {
groupFilter = 'sys_idIN' + groupIds.join(',') + ',c6c828c453751300ba3dddeeff7b1219'; // xyz is the sys_id of the exception group
return groupFilter;
}

},
    type: 'GroupFilter'
};

 

 

 

 

 

 

 

 

 

To use this script include as a reference qualifier, you can use the following script:

new GroupFilter().filterGroups()

 

 

 




Kindly mark my answer as Correct and helpful based on the Impact.

Regards,

Siddhesh

 

Hello @JohnDF , 

Please see following link for callinf script include in reference qualifier.

https://www.servicenow.com/community/developer-forum/call-script-include-from-reference-qualifier/m-...

@Siddhesh Gawade hi thanks for reply,

 

here is my script include:

 

JohnDF_0-1703169733337.png

 

 

Here is my reference field on the case with the call.

 

JohnDF_1-1703169805607.png

 

 

the uer in the cc group can still see all groups when i search on case form in assingned group.

What could be the problem?

Does it calling the script include? Have you checked using logging to confirm does the script include is being called.