Hide catalog variable if logged in user has “Is Manager” as true
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
Trying to design a catalog form where if the it checks the logged in user - and if that user’s “Is Manager” property = true, then one of the attachment variable that required for manager approval is hidden.
From what I’ve found online this needs to be done as client script instead of catalog UI policy - is that correct? I’m having trouble scripting this one and would be grateful for any ideas. Thanks!
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Dee123 ,
you can create a catalog client script please follow below steps -
- Name: Hide Manager Attachment
- Catalog Item: Select your item
- UI Type: All or Desktop
- Type: onLoad
function onLoad() {
// Get the logged-in user's sys_id
var userSysId = g_user.userID;
// Call a GlideAjax script to check if the user is a manager
var ga = new GlideAjax('CheckIfManager');
ga.addParam('sysparm_name', 'isUserManager');
ga.addParam('sysparm_user_id', userSysId);
ga.getXMLAnswer(function(response) {
var isManager = response;
if (isManager == 'true') {
// Hide the attachment variable (replace 'attachment_variable_name' with actual name)
g_form.setDisplay('attachment_variable_name', false);
}
});
}
Please mark it as complete if this resolved your query and close the thread .
Thanks,
Rithika.ch