How to hide comments field if doesnot belong to particular group in native KB UI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 05:28 AM
Hi Experts,
We have a requirement to hide comments field if user doesn't belong to particular group in native KB UI.
May i request experts to share solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 10:27 AM
Hello,
There is a checkbox on Knowledge Article called 'Dissable commenting', this dissable comments for all users for particular article. I think this behavior could be also set on Knowledge Base level.
To display it for certain users you need to do a customization.
On Portal comments are basically displayed by a widget. Locate correct widget, clone it and include additional condition to Server script logic to display comments block.
For example I found widgets called 'Knowledge Article Comments' or 'KB Article Comments'.
- Specify Portal you need to hide comments in.
- What is exact condition to hide/display comments to certain users?
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 09:45 PM
Hi Martin,
Thanks for quick reply, our requirement is not on the serviceportal view, on load of the viewarticle>kb_view, comments should be visible only to particular group.
Thanks, Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 10:45 PM
- Page 'kb_view.do' is a UI Page located in UI Page table [sys_ui_page] (Sys ID: 11efa742eb4221007128a5fc5206fe1a)
- To display KB Article data, it uses logic located in Script Include 'KBViewModel()' that extends OOB Script Include 'KBViewModelSNC()'
- In Script Include 'KBViewModelSNC()', there is a function canShowKBFeedback() that handles logic with validation if comments should be displayed
So you have to customize the logic
- Open Script Include 'KBViewModel' (SysID: 994116f1d73221004792a1737e610371)
- Paste customized function
canShowKBFeedback: function() {
var showFeedback = gs.getProperty('glide.knowman.show_user_feedback');
showFeedback = showFeedback.toLowerCase();
if (showFeedback === 'never' || this.knowledgeRecord.disable_commenting)
return false;
var roles = gs.getProperty('glide.knowman.show_user_feedback.roles');
if (roles != null && roles != '') {
var hasRole = gs.hasRole(roles);
if (hasRole == false)
return false;
}
//Add logic with custom condition regarding group member
var currentUser = gs.getUser();
var group = 'Allowed group'; // Add your logic to retrieve group
if (!currentUser.isMemberOf(group)) {
return false; // Don't display comments section
}
return true;
},
Before:
After:
If my answer helped you, please mark it as correct and helpful, thank you 👍
Martin