CMDB Workspace - Home page Quick Links

Bruno Hernandez
Tera Contributor

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. 

2 REPLIES 2

Iraj Shaikh
Mega Sage
Mega Sage

Hi @Bruno Hernandez 

 

Please follow the steps below to accomplish your requirement:

  • Create new reference 'Group' field on sn_cmdb_ws_quick_links table as shown below:Screenshot 2024-01-10 at 5.19.36 PM.png

 

  • Create new before query business rule on sn_cmdb_ws_quick_links table as shown below:Screenshot 2024-01-10 at 5.22.25 PM.png

    Screenshot 2024-01-10 at 7.08.47 PM.png

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-mandatoryScreenshot 2024-01-10 at 5.36.34 PM.png

 

  • Optional: Create new UI policy "User Field Visibility"
  • Condition: Group is empty
  • UI Policy Action:  Field name-user, Mandatory-True, Visible-TrueScreenshot 2024-01-10 at 5.52.41 PM.png

  • Optional: Create another new UI policy "Group Field Visibility"
  • Condition: User is empty
  • UI Policy Action:  Field name-u_group, Mandatory-True, Visible-TrueScreenshot 2024-01-10 at 5.56.17 PM.png

 

Please mark this response as correct or helpful if it assisted you with your question.

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.