CMDB Workspace - Home page Quick Links
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 12:36 PM
Hello everyone,
I am working with CMDB Workspace.
In the home page we have Quick links section which are kept in sn_cmdb_ws_quick_links table
The table has the following fields:
- Order
- Title
- URL
- User
As far as we know, this table uses User field to make it available according to the user ID kept there.
My question is, can this be done with a certain group of users instead of adding them one by one?
Let's say as an example, I have "IT" group, I want this link only available for this particular group.
Is there a way to achieve this? I tried editing the Form Layout by adding a Group field, but I cannot make this attribute work properly.
Any help is appreciated, thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 04:29 AM - edited 01-10-2024 05:39 AM
Please follow the steps below to accomplish your requirement:
- Create new reference 'Group' field on sn_cmdb_ws_quick_links table as shown below:
- Create new before query business rule on sn_cmdb_ws_quick_links table as shown below:
In query Business rule's advanced tab
Condition:
!gs.hasRole('admin') && !gs.hasRole('sn_cmdb_admin')
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Only apply the rule when a user is logged in
if (gs.getUserID()) {
// Get the current user's groups
var userGroups = getUserGroups(gs.getUserID());
// Add a query to filter the Quick Links by the user's groups
current.addQuery('u_group', 'IN', userGroups);
}
})(current, previous);
function getUserGroups(userId) {
var groupList = [];
var userGrp = new GlideRecord('sys_user_grmember');
userGrp.addQuery('user', userId);
userGrp.query();
while (userGrp.next()) {
groupList.push(userGrp.group.toString());
}
return groupList;
}
- Set 'User' field of sn_cmdb_ws_quick_links table non-mandatory
- Optional: Create new UI policy "User Field Visibility"
- Condition: Group is empty
- UI Policy Action: Field name-user, Mandatory-True, Visible-True
- Optional: Create another new UI policy "Group Field Visibility"
- Condition: User is empty
- UI Policy Action: Field name-u_group, Mandatory-True, Visible-True
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 06:10 AM
Thank you so much for replying and your time!
I'll try with this solution then I'll tell you if it worked.
I'll keep you updated.