You do not have sufficient privileges to access this knowledge item message in SP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Hi,
This is an OOB box behavior on Service Portal that--> if a non admin user has already opened an article that was not retired when opened, but this article got retired from the backend and when the non admin user reloads the page they get "You do not have sufficient privileges to access this knowledge item", same with the favorites or permalink URL as well. This is actually a misleading message that might confuse them with role issues. I want this message to change something for retired when the article gets retired. If they are not in a group then this message"You do not have privileges " is fine.
The OOB widget is --> Knowledge Article Content
For admins it does not show any message, it just shows retire beside the article number which is fine.
I tried this at line 198 but the knowledgeRecord is giving null data everytime for non admin user, it works somehow for admins, not able to understand why does not it work for non admin users.
.....................>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
since in backend the article has been retired and when user reloads the IF won't work due to ACL block
try this
-> Instead of using knowledgeRecord.getValue, check if knowledgeRecord is null. Then, use additional logic to determine whether it's due to retirement or other ACL issues.
// Server-side script in Knowledge Article Content widget
var sysId = $sp.getParameter("sys_id") || $sp.getParameter("sysparm_article");
var record = $sp.getRecord('kb_knowledge', sysId);
if (!record) {
// Try to fetch with GlideRecord for fallback information
var gr = new GlideRecord("kb_knowledge");
if (gr.get(sysId)) {
if (gr.getValue("workflow_state") == "retired") {
data.messages.ARTICLE_RETIRED = gs.getMessage("This knowledge item has been retired");
} else {
data.messages.INSUFFICIENT_PREVILEGES = gs.getMessage("You do not have sufficient privileges to access this knowledge item");
}
} else {
data.messages.RECORD_NOT_FOUND = gs.getMessage("Knowledge record not found");
}
} else {
// Render as normal, with record available
}
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
2 hours ago
Hi Ankur,
I tried something like this before but no luck, it works for admin but not for non amin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited 2 hours ago
Hello @Harsha34
Use the following code in the else part at line no 198:
if(!kbViewModel.canAccessRetiredArticle(kbViewModel.knowledgeRecord)){
data.messages.INSUFFICIENT_PREVILEGES = gs.getMessage("This article is retired");
}else{
data.messages.INSUFFICIENT_PREVILEGES = gs.getMessage("You do not have sufficient privileges to access this knowledge item ");
data.messages.RECORD_NOT_FOUND = gs.getMessage("Knowledge record not found");
}
Screenshot for reference:
Make sure that you have cloned the widget and replaced the original widget with cloned one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20 seconds ago
Hey Nehal,
This code worked for retired articles but now it is overriding the existing message that was coming for those articles which cannot by access by someone which is "You do not have sufficient privileges".
Please suggest.
Thanks