• Kaushal Pitroda
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello,

I have a piece of test code to create and publish the articles and it goes as below..
 
Product_Info__kav  testArticle = new Product_Info__kav ();
testArticle .Title = 'Test Prod Info';
testArticle .Summary = 'Test Summary';
testArticle .URLName = 'Test Prod Info';
insert testArticle ;

Product_Info__kav insertedTestArticle = [SELECT KnowledgeArticleId FROM Product_Info__kav WHERE ID = :testArticle.Id];
            
KbManagement.PublishingService.publishArticle(insertedTestArticle.KnowledgeArticleId, true);  

The issue is this test code works fine in 3 sandboxes but it is failing in one particular sandbox and I am getting the below exception in Line #9.
 
System.HandledException: You can't perform this action. Be sure the action is valid for the current state of the article, and that you have permission to perform it.

I checked the knowledge settings, permission set access for the article types and everything looks fine but unable to find out why this error is happening and that too for just one sandbox. Any help is appreciated