I have some code that queries KnowledgeArticleVersions and I'm trying to test it. In order to do so, I first need to add articles...
@isTest
public class ORC_TestUtils {
public static void addPublishedArticle(){
Issue__kav article= new Issue__kav(
Title = generateRandomString(),
UrlName = generateRandomString()
);
insert article;
//using object because all objects have the same properties
KnowledgeArticleVersion a = [SELECT KnowledgeArticleId FROM KnowledgeArticleVersion WHERE Id = :(Id) article.get('id')];
KbManagement.PublishingService.publishArticle(a.KnowledgeArticleId, true);
}
}
This seems to work fine when I test it in my sandbox, but when I try to validate in production, it fails with this message:
System.NoAccessException: Insufficient Privileges: You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.
I've tried using System.runAs()
with a sys admin user but I get the same results... Anyone have any idea why this is happening?