how to hide/show list collector variable options for only two groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 09:34 PM
hi can anyone help me for scenario for there is a list collector variable in catalog item with name ' access needed' and it is referencing access table, there are options with name ' okta retail' and ' okta prod' i want to show these two options in list collector variable only for process specilist group memners and service now dev group.
i.e
Only allow ServiceNow Development and Process Specialist groups to see this option in list collector variable and hide from view for all other group members
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 09:46 PM
Hi @raj765_32
If possible, can you share some screenshot please...!!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 09:49 PM - edited ‎10-16-2023 09:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 10:14 PM - edited ‎10-16-2023 10:17 PM
Hi @raj765_32
1.You can write script include to check group membership of current user & return the query depending upon that.
2.use reference qualifier on list collector variable to call that script include.
Script include :
Name : accessUtils
Function : getAccessNeeded
var accessUtils = Class.create();
accessUtils.prototype = {
initialize: function() {},
/*1. Get access needed depending upon user group */
getAccessNeeded: function(userId) {
/*2. Declare variable to return value */
var query;
/*3. Check group membership of user */
var grMem = new GlideRecord('sys_user_grmember');
grMem.addEncodedQuery('group.nameINServiceNow Development,Process Specialist^user=' + userId);
grMem.query();
if (grMem.query()) {
/*4.1 User is member of groups */
query = "put your query here if user is member of group";
} else {
/*4.2 User is not memeber of groups */
query = "put your query here if user is not member of group";
/*for example -
query = "fieldName!=okta retail^ORfieldName!=okta prod";
*/
}
/*4. Return the query */
return query;
},
type: 'accessUtils'
};
Reference Qualifier :
javascript: new accessUtils().getAccessNeeded(gs.getUserID());
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 10:23 PM
no this is not working, can you help me with client scripts and display business rule?