Mass updating published articles

This method creates draft articles from online articles, so this happens because one or more of those online article already has a draft article so you cannot create another draft article(you cannot have 2 drafts for a single article at the same time).

This should work for you

    for(FAQ__kav k : [SELECT Id, ArticleNumber, KnowledgeArticleId
                      FROM FAQ__kav
                      WHERE PublishStatus = 'Online'  AND Language = 'en_US']){
         try{
             String onlineK=KBManagement.PublishingService.editOnlineArticle(k.KnowledgeArticleId,false);
        }
     catch(exception e){
         //nothing to do here, draft existed 
     }                                        


  }

Tags:

Apex

Knowledge