How can hide group details based on catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 09:54 AM
Hi All,
I have a variable set. In that variable set I have a field is requested for.
I used that variable set in all catalog items. But based on catalog item few of the users I need to hide on requestor variables.
How can I do that. I tried with reference qualifier and script include but it's not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 03:47 PM
i written below script but not working
javascript: new Hideuser().getUser(current.cat_item.sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 06:05 PM
@Lakshmi53 in your script include try something like below.
var Hideuser = Class.create();
Hideuser.prototype = {
initialize: function() {},
getUser: function(catItemId) {
var user = [];
if (catItemId === '7899999') {
var info = new GlideRecord('sys_user');
info.addEncodedQuery('active=true^sys_id!=123');
info.query();
while (info.next()) {
user.push(info.sys_id.toString());
}
return user.length > 0 ? 'sys_idIN' + user.join(',') : 'sys_idINempty';
} else {
return 'operational_status=1';
}
},
type: 'Hideuser'
};
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 07:44 PM
I varified through the logs catItemId I am receiving undefined

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 07:35 PM
Hello Lakshmi,
It would be best to do it with Client callable Script include and onLoad client script to achieve this like below.
Script include
var HideRequestor = Class.create();
HideRequestor.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRequestorVisibility: function() {
var userId = this.getParameter('sysparm_user_id');
var usersToHide = ['USER_SYS_ID_1', 'USER_SYS_ID_2'];
return usersToHide.includes(userId) ? 'true' : 'false';
},
type: 'HideRequestor'
});
On load client script
function onLoad() {
var userId = g_user.userID;
var ga = new GlideAjax('HideRequestor');
ga.addParam('sysparm_name', 'getRequestorVisibility');
ga.addParam('sysparm_user_id', userId);
ga.getXMLAnswer(function(response) {
var shouldHide = response.responseXML.documentElement.getAttribute("answer");
if (shouldHide === 'true') {
g_form.setDisplay('requested_for', false);
} else {
g_form.setDisplay('requested_for', true);
}
});
}
Hope this helps.