Hide retire button Knowledge article based on user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2025 10:26 PM
In the knowledge base table there is custom field with reference to group table
Only user belongs to this group can retire this specific knowledge articles attached to this KB.
If the user not belongs to this group should not retire i/e retire button should be invisible for them in kb article form.
How can i achieve this please help me to find the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2025 11:02 PM
Hi @nivethika ,
Navigate to the Retire ui action and add the condition to it gs.getUser().isMemberOf('group1') // pass your group name instead of group1
If this information proves useful, kindly mark it as helpful or accepted solution.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2025 11:21 PM
you can use this logic in the Retire UI button condition
OR
I will suggest you can avoid updating the OOTB UI action and use before update business rule and then stop user from retiring
BR Condition: State Changes To Retired
Script:
if (current.kb_knowledge_base.customFieldName != '' && !gs.getUser().isMemberOf(current.kb_knowledge_base.customFieldName)) {
current.setAbortAction(true);
gs.addErrorMessage('You are not member of group');
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2025 11:25 PM
Thank you @Ankur Bawiskar,
Your logic i tried it worked well, but i need to hide the Retire ui action itself so that we can block the user not belong to that group to do retire
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2025 11:37 PM
the UI action condition field is with max length 254 so you will have to use script include to include that long condition
For Example: this UI action, do this for others as well
Before:
After:
var RetireButtonVisibility = Class.create();
RetireButtonVisibility.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRetireCondition: function(current) {
// if custom field on KB base is empty then use OOTB condition
if (current.kb_knowledge_base.customFieldName == '')
return !(new KBCommon().isStackNameDialog()) && (new KBKnowledge().canRetire(current)) && (new KBCommon().canProvideReplacementArticle()) && (current.sys_class_name != 'kb_knowledge_block')
else // if not then add your extra condition for group check
return !(new KBCommon().isStackNameDialog()) && (new KBKnowledge().canRetire(current)) && (new KBCommon().canProvideReplacementArticle()) && (current.sys_class_name != 'kb_knowledge_block') && (gs.getUser().isMemberOf(current.kb_knowledge_base.customFieldName))
},
type: 'RetireButtonVisibility'
});
Add this in UI action condition: new RetireButtonVisibility().checkRetireCondition(current)
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader