function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shraddha AherShraddha Aher 

Getting error : System.QueryException: Insufficient access rights: you cannot access draft articles.

Hi,

I am getting following error when I run my test class:

System.QueryException: Insufficient access rights: you cannot access draft articles.

The line for which it gives error is:

String q = 'select ' +pkb_Controller.join(pkb_Controller.kavFields, ',')+ ' from KnowledgeArticleVersion where Id = \'' +kavObj.get('Id')+  '\' and PublishStatus = :publishStatus';
kavObj = (KnowledgeArticleVersion)Database.query(q);

here I am trying to query the 'KnowledgeArticleVersion' object and I am getting the error.
How to give access for this object ? I am system administrator so should have the access by default.
Abhi_TripathiAbhi_Tripathi
Hi,

If you don't have access to the object, go to system admin profile and give read , edit permission on this object.

And its just a suggesstion, why you are querying database records in the test class, its not good for practice.

For more detail about test class go for this post : http://abhithetechknight.blogspot.in/2013/10/salesforce-test-class-basics.html

R
egards,
Abhi Tripathi
Salesforce Certified Developer
Vinit_KumarVinit_Kumar
What's the value in variable publishStatus ??
Pramod SharmaPramod Sharma
Please check

A user must have the “Manage Articles” permission enabled to use Online. 'Manage Articles'
MagulanDuraipandianMagulanDuraipandian
Hi,
Kindly check "Knowledge User" check box is checked on your user detail page.

If this solves your problem, kindly mark it as the best answer.
Hit Like, if it saved your work :-)

Regards,
Magulan
http://www.infallibletechie.com
MagulanDuraipandianMagulanDuraipandian
http://www.infallibletechie.com/2014/05/how-to-enable-as-knowledge-user-in.html