Requirement is to hide assignment groups from drop down if requestor is a member of the group

sravya03
Tera Contributor

Requirement is to hide assignment groups from drop down if requestor is a member of the group in catalog item.

Example i have a ABC variable which is referenced to sys_user_group table and will have active groups in drop down.

I have a variable XYZ where we need to give user name who need access, so when person name is given on ABC drop down only group which he is not member should be visible.

ABC is a variable in multirow and XYZ is single row variable

13 REPLIES 13

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @sravya03 

 

https://www.servicenow.com/community/developer-forum/hide-values-in-drop-down/m-p/2168097

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Vijendra Sainy
Giga Guru

You need to write the script include for the filter.  Pass the user name and fetch the list of group from group member table where the user is not part of. 

 

Call this script include in advance reference qualifier. In reference qual you can use javascript:new myScriptInclude().my_refqual() to call the function from script include which will return the group.

@Vijendra Sainy 

 

Can you pls provide script include if possible

There you go.

 

var grpMember = new GlideRecord("sys_user_grmember");
grpMember.addQuery("user", gs.getUserID());
grpMember.query();
var groupsPartOf = [];
while(grpMember.next()) {

 

     groupsPartOf.push(grpMember.group.toString());
}
var grGroups = new GlideRecord('sys_user_group');
grGroups.addQuery('sys_id', 'NOT IN', groupsPartOf);
grGroups.query();
var groupsNotPartOf = [];
while (grGroups.next()) {
    groupsNotPartOf.push(grGroups.name.getDisplayValue());
}
gs.info("Groups not part of: " + groupsNotPartOf.join(', '));