Hide "Actions" Button from kb_article view

Klug
Tera Contributor

How can I hide the button in the photo below for groups that are not responsible for the KB?

I used this 

<j:if test="${gs.hasRole('itil')}">

<j:if test="${showUpdateAction}">

  <button id="editArticle" title="${gs.getMessage('Edit content')}" class="btn btn-default navbar-btn snc-article-header-toolbar-button">${gs.getMessage("Edit")}</button>

  </j:if>

</j:if>.

But didn't work.

Klug_0-1698594806114.png

 

5 REPLIES 5

Amit Gujarathi
Giga Sage
Giga Sage

HI @Klug ,
I trust you are doing great.

Peter and Tai have provided valuable insights. I'll elaborate on their points and guide you through hiding the "Actions" button based on user roles or groups.

  1. Using ACLs (Access Control Lists):

    • ACLs are indeed a powerful way to control access to data within tables. For your case, you would be looking at the kb_knowledge table.
    • You can create or modify an ACL to restrict the "write" or "edit" operation based on the user’s role or group membership.
  2. Customizing the UI with Scripting:

    • If you prefer a scripting approach, you can customize the visibility of the button directly in the client script or UI policy.
    • Here’s a sample script that you might find useful:
function onLoad() {
    // Check if the user has a specific role or belongs to a specific group
    if (!g_user.hasRole('your_specific_role') && !g_user.isMemberOf('your_specific_group')) {
        // Hide the "Actions" button
        var editButton = gel('editArticle');
        if (editButton) {
            editButton.style.display = 'none';
        }
    }
}

Modifying the Script Include:

  • As Tai mentioned, you can modify the KBViewModelSNC script include, specifically the canContributeToKnowledgeBase function, to customize the visibility based on your conditions.

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi