Hide menu in service portal for group
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 07:04 AM - edited 06-05-2023 07:12 AM
Hello. Pls, How do I hide the visibility of a service portal menu for a certain group? tks
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 07:54 AM
Hi @ALe1 ,
Hope you are doing great.
- Navigate to the Service Portal --> "Service Portal" > "Portals" > "Service Portal Configuration."
- Identify the specific menu you want to hide for a certain group. Note down the sys_id of that menu, as we'll need it later.
- Now, create a new UI Script. UI Scripts allow you to add custom JavaScript code to the Service Portal.
- Give the UI Script a meaningful name, such as "Hide Menu for Group."
- In the script code section, you'll need to write JavaScript code that checks the current user's group membership and hides the menu if the user belongs to the specified group.
// Retrieve the current user's group membership
var groups = gs.getUser().getMyGroups();
// Define the sys_id of the group for which the menu should be hidden
var groupSysID = "ENTER_GROUP_SYS_ID_HERE";
// Check if the current user belongs to the specified group
if (groups.indexOf(groupSysID) !== -1) {
// Hide the menu by targeting its DOM element
var menuElement = document.querySelector("ENTER_MENU_SELECTOR_HERE");
if (menuElement) {
menuElement.style.display = "none";
}
}
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma
Regards,
Riya Verma