- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday - last edited Wednesday
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.
.....................>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friday
Hey @Harsha34 ,
Please try the following code in the else part at line no 198:
var KBViewModelV2 = new global.KBViewModelSNC_v2();
var kbSysID = $sp.getParameter("kb_sys_id"); // use your parameter name
var isRetired = KBViewModelV2.getWorkflowStateByArticleNumber(kbSysID);
if(isRetired){
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");
}
new script include:
var KBViewModelSNC_v2 = Class.create();
KBViewModelSNC_v2.prototype = Object.extendsObject(KBCommon, {
initialize: function() {},
getWorkflowStateByArticleNumber: function(articleSysId) {
var kb = new GlideRecord('kb_knowledge');
kb.addQuery('sys_id', articleSysId);
kb.orderByDesc('version');
kb.query();
if (kb.next()) {
return kb.getValue('workflow_state') == 'retired';
}
return false;
},
type: 'KBViewModelSNC_v2'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
Hello @Harsha34 ,
To change the current behavior, you would need to either customize the KBViewModelSNC Script Include or clone it and update the associated widget accordingly.
By default, KBViewModelSNC is configured to allow only admin users to access retired knowledge articles on the portal. Other users will receive the message:
"You do not have sufficient privileges to access this knowledge item."
I would strongly recommend avoiding this customization, as it could lead to missing important updates to related script includes or widgets in future platform releases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday - last edited Thursday
Hey Nehal,
I guess you misunderstood my requirement. Non admin users should get a message saying “Article is retired” when they are accessing retired articles, this is already working expected. But now if non admin users try to access an article to which they do not have read access they should get “You do not have sufficient privileges “.
Somehow the code is not entering else part even when the article is not retired. Ideally this code should run only when article is retired as this is already defined in function canAccessRetiredArticle but when article is not retired it should run else part right?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friday
Hey @Harsha34 ,
Please try the following code in the else part at line no 198:
var KBViewModelV2 = new global.KBViewModelSNC_v2();
var kbSysID = $sp.getParameter("kb_sys_id"); // use your parameter name
var isRetired = KBViewModelV2.getWorkflowStateByArticleNumber(kbSysID);
if(isRetired){
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");
}
new script include:
var KBViewModelSNC_v2 = Class.create();
KBViewModelSNC_v2.prototype = Object.extendsObject(KBCommon, {
initialize: function() {},
getWorkflowStateByArticleNumber: function(articleSysId) {
var kb = new GlideRecord('kb_knowledge');
kb.addQuery('sys_id', articleSysId);
kb.orderByDesc('version');
kb.query();
if (kb.next()) {
return kb.getValue('workflow_state') == 'retired';
}
return false;
},
type: 'KBViewModelSNC_v2'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friday
Hey Nehal,
I tried this, did few modifications according to my custom application and it worked . You are brilliant and helpful too, we find very few people who are helpful like you in community 🙂
Loads of thanks!!