this._knowledgeHelper.canRead(knowledgeGR) function not returning record as expected

Eric Viets
Mega Expert

In the Script Include KBKnowledge, I have copied and pasted the canRead: function(knowledgeGR) function from KBKnowledgeSNC because it seemed to be the function where I was finding the problem.

Indeed, when I commented out various parts of the function, the problem became clear.

When I did the below comment, the record showed up for the user I was testing with.

if (/* this._knowledgeHelper.canRead(knowledgeGR) && */
       (knowledgeGR.workflow_state == 'published' || 
	knowledgeGR.workflow_state == 'outdated'  || 
	this._knowledgeHelper.canReadUnpublished(knowledgeGR))) {

The natural reaction is to say that the user doesn't have read access to the article; however, the article is in a knowledge base which is open to the public (i.e., the CanRead user criteria on the knowledge base is empty).

I cannot seem to find the code behind _knowledgeHelper.canRead anywhere.

Anyone have any suggestions on how I can further troubleshoot this?

I will also note that I am viewing the record through the Knowledge Feedback table, if that makes a difference.

6 REPLIES 6

Hadyn
Tera Expert

Through class inheritance you will find _knowledgehelper in the KBCommonSNC script include.

KBCommonSNC.prototype = {
	
	VERSIONING_PLUGIN : 'com.snc.knowledge_advanced',
	initialize: function() {
		this._knowledgeHelper = new SNC.KnowledgeHelper();
	},

 

I don't think we can see the code within canRead() since it's core code.

I assume it checks the user criteria at the article level but it may also check at the Knowledge Base level aswell.

Although this post contains info specifically about canContribute() it is helpful.

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

"It is not implemented in a Script Include, this is core application code that is exposed to scripting via an interface. canContribute will return true if the user is admin, is the owner or manager of that KB, or if that user has a matching user criteria. The wiki article says that if there are no user criteria any ESS user can contribute but the code seems to contradict that."

Correct, we cannot see the code.

Seeing that canContribute references admin, owner, or manager is consistent with my findings (those three 'roles' can also view the appropriate feedback records); however, I do not believe it is accurately determining if the user has a matching user criteria record.

I have submitted INT3675324 in the HI Service Portal.

Hi Eric,

I also think it is not working for matching user criteria. What was the outcome from HI Portal?

Could you please let me know?

Thanks& Regards,

Mithun K R

nagadeepika
Kilo Contributor

Hi @Eric Viets 

What is the solution proposed for this..as we are looking for similar issue. Help here!