Hide Create Incident button on Knowledge Table

vivek72
Tera Guru

Hi,

 

I have below 2 requirements and would like to understand the easiest way to implement these:

1. How shall I disable 'Create Incident' button on Knowledge table for a particular Knowledge base only.

    like out of 6, only members from 1 particular group shouldn't be able to see 'Create Incident' button.

2. How to disable Knowledge templates for some Knowledge bases, need only 1 template (sys_wizard_answer) for a particular Knowledge base, rest all templates should be visible for all Knowledge bases.

1 ACCEPTED SOLUTION

Hi @vivek72 ,

 

Can you update UI Macro = "kb_view_common" XML like below.

After line 6, add the code marked in bold to evaluate whether user is part of Group whom you need to exclude

 

<g:evaluate jelly="true">
var knowHelp = new SNC.KnowledgeHelper();
var showCreateIncident = !kbViewInfo.isInPopup && !jelly.sysparm_no_create_incident && !kbViewInfo.hideFeedbackOptions && RP.getParameterValue('sysparm_class_name') != "kb_knowledge_block";

// Add this section to check for group membership
var excludeGroup = gs.getUser().isMemberOf('Name of the Group to Exclude'); // Replace 'Name of the Group to Exclude' with the actual group name
if (excludeGroup) {
showCreateIncident = false; // Set to false if the user is a member of the excluded group
}

var showMoreInfo = !kbViewInfo.isInPopup && !jelly.sysparm_no_info;

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

Thanks, GP

View solution in original post

6 REPLIES 6

G Ponsekar
Mega Guru

Hi @vivek72 ,

 

For the first requirement , you need to update "Create Incident" UI Action condition

  • Open the "Create Incident" UI Action.
  • Examine the "Condition" field. This field contains the script that determines when the UI action is visible.
  • Modify the script to include conditions for the specific Knowledge Base and User Group. You'll need to add logic similar to this:
    javascript
    (current.kb_knowledge_base.name != "YOUR_KNOWLEDGE_BASE_NAME") && (!gs.getUser().isMemberOf("YOUR_GROUP_NAME"))
    Use code with caution.
    • Replace "YOUR_KNOWLEDGE_BASE_NAME" with the actual name of the Knowledge Base where you want to disable the button.
    • Replace "YOUR_GROUP_NAME" with the name of the group that shouldn't see the button.

For the second requirement, you can try like below

  1. Access Knowledge Base and Templates:
    • Navigate to Knowledge > Administration > Knowledge Bases.
    • Open the specific Knowledge Base where you want to restrict templates.
  2. Manage Article Templates:
    • On the Knowledge Base form, click the Article Template tab.
    • Click Edit to modify the list of available templates.
    • If the Article Templates related list is empty, articles can be created using any template. If templates are listed, articles in that knowledge base can only be created using one of those templates.
  3. Restricting Templates (for all except one Knowledge Base):
    • For the Knowledge Bases where you want all templates visible, ensure the "Article Templates" related list is empty or contains the desired templates.

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

Thanks, GP

 

Hi @G Ponsekar ,

 

Thanks for the response.

Unfortunately, I didn't find any  "Create Incident" UI Action on Knowledge table where I can update the required conditions.

It should be OOTB, please share URL for this button if possible.

Hi @vivek72 ,

 

Are you asking about knowledge article table? I believe there is no OOTB UI Action called "create incident" in article table

Please share screenshots

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

Thanks, GP

 

Hi @G Ponsekar ,

 

you can find details here :

https://www.servicenow.com/community/united-kingdom-snug/create-incident-button-is-showing-on-knowle...

 

Not sure how shall I modify this UI macro to exclude a particular group from viewing this Create Incident button.