- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 08:19 AM
Detail requirement is as below:
The "Edit" button in a knowledge article should only be available to those users, who:
a. Are the author of the respective Knowledge article, OR
b. Are part of the Assignment Group of the Configuration Item used for creating the Knowledge article
----------------------------------------------------------------------------------
While analyzing this I found that in "kb_view_common_header_toolbar" UI Macro the below condition is coded for 'Edit' button.
<j:if test="${showUpdateAction}">
<button id="editArticle" title="${gs.getMessage('Edit content')}" class="btn btn-default navbar-btn snc-article-header-toolbar-button">${gs.getMessage("Edit")}</button>
</j:if>
Here variable showUpdateAction is being set in another UI Macro "kb_view_common"
After that I am lost. Not exactly able to understand how and where the conditions are written and how can I modify to implement my requirements.
Any help is greatly appreciated. Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Knowledge Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 03:37 PM
Your question got me to rethink my answer.
I tought instead of doing all these scripts override which are global and override OOTB stuff, you can simply create a scripted user criteria and apply it as the only user criteria for the required knowledge bases. However, these user criteria are somehow cached in the user session, so for example: a user is the author of an article, he changes the author to someone else so that he should no longer have write access, however he keeps the write access because of a weird caching with user criteria. I conclude that user criteria should not be used to be dynamic with the record.
However, your point about the canContribute method is good, you could in fact make this simpler by overriding the canContribute method that is defined in KBCommon. And remove the previous overriding I proposed:
var KBCommon = Class.create();
KBCommon.prototype = Object.extendsObject(KBCommonSNC, {
initialize: function(){
this._knowledgeHelper = new SNC.KnowledgeHelper();
this._knowledgeHelper.canContribute = function(knowledgeGR){
var defaultContribute = new SNC.KnowledgeHelper().canContribute(knowledgeGR);
if(!defaultContribute){
return false;
}
var isAdmin = gs.hasRole('admin');
if(isAdmin){
return true;
}
var isKnowledgeBase = knowledgeGR.getRecordClassName() == 'kb_knowledge_base';
if(isKnowledgeBase){
return true;
}
var isAuthor = knowledgeGR.author == gs.getUserID();
if(isAuthor){
return true;
}
var isMemberOfCIGroup = gs.getUser().isMemberOf(knowledgeGR.cmdb_ci.support_group);
if(isMemberOfCIGroup){
return true;
}
return false;
};
},
type: 'KBCommon'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2017 01:02 PM
Thanks Stacy for bringing the good point.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2017 04:38 PM
Unfortunately, the article-specific criteria is just for Can Read and Cannot Read. There's no criteria for Can Edit and Cannot Edit at the article level. I would think the pattern would be easy enough to replicate, though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 02:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 10:21 AM
Hi Swathi - What is your Current SNOW instance version?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 07:11 PM
We are using Istanbul Version.