Show only user own comments for knowledge article in service portal

Rahuldoon
Tera Contributor

Hi,

II have a requirement to show only user own comment for a knowledge article on service portal. 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 @Ankur Bawiskar  @Chuck Tomasi  @Aman Kumar  Is this the right way or something i am missing?

find_real_file.png

KB Article Hide comments instance.

find_real_file.png

4 REPLIES 4

Erik Stolberg
Tera Guru

It looks like you modified kb_article page, but most new tenants are likely using the kb_article_view page when viewing articles. Even if the URL doesn't show this page, there may be a Page Route Map setup to redirect users from kb_article to kb_article_view on some or all service portals.

Hi Erik,

That is correct. So how we could achieve this. We have Knowledge Article Comments widget which is in kb_article_view page.

Any help will be appreciated?

I'm not sure what you're asking me. You created a cloned/custom widget "KB Article Hide Comments" and added it onto the kb_article page... that's what you have showing in your screenshots...

What I said is you may be using the kb_article_view page instead, so you need to add your customized widget onto that page. Have you done that, and removed the baseline widget from that page, as you did on the other page? Are you saying this is still not working? Please be more clear with what you have done and what you are asking for assistance with in the future.

Aman Kumar S
Kilo Patron

Hey,

Found one relevant article on the community:

Show only user's comments on KB Articles

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar