The CreatorCon Call for Content is officially open! Get started here.

Hide the other user comments and show user own comments in kb article

Rahuldoon
Tera Contributor

Hi,

I need to have all users are allowed to add comments to Knowledge Articles, but Users can only see their own comments, Knowledge Managers can see all comments.

Please help how to achieve this.

Regards,

Rahul

2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, you haven't clearly indicated where\how the KB articles are being viewed, based on 'topic' I assume via a portal widget? So one of these posts might be the answer your are looking for, but without specific details I am guessing.

https://community.servicenow.com/community?id=community_question&sys_id=b6781c3bdb4fa410190b1ea6689619f3

https://community.servicenow.com/community?id=community_question&sys_id=e2385a15db195c90d58ea345ca96195b

 

 

 

Rahuldoon
Tera Contributor

Hi,

I tried to clone the widget "kb article comments" and created cloned "kb article hide comments" widget. Updated the getfeedback function as below to show only logged in user comments.

// private functions
function getFeedback(articleID) {
var feedback = [];
var gr = new GlideRecord("kb_feedback");
gr.addQuery("article", articleID);
gr.addQuery("flagged", false);
gr.addQuery("user", gs.getUserID());  // added this line
gr.addNotNullQuery("comments");
gr.orderByDesc('sys_created_on');
gr.query();
while (gr.next()) {
var f = {};
add('comments');
add('rating');
add('user');
add('useful');
add('sys_created_on');
feedback.push(f);
}

return feedback;

 

But still all users comments are showing on service portal kb article. Please see below how i set up cloned widget in kb_article page. Please help is this the right way or something i am missing.

find_real_file.png

KB Article Hide comments instance.

find_real_file.png