You need to sign in to do that
Don't have an account?
hiteshwar marni
archive
list<KnowledgeArticleVersion> hrlist = new list<KnowledgeArticleVersion>();
String articleId = '';
hrlist=[SELECT ArticleType,Id,KnowledgeArticleId,Language,PublishStatus FROM KnowledgeArticleVersion WHERE ArticleType = 'How_To_HR__kav' AND Language = 'en_US' AND PublishStatus = 'Online'limit 100];
for(KnowledgeArticleVersion hr:hrlist)
{
articleId = hr.KnowledgeArticleId;
KbManagement.PublishingService.archiveOnlineArticle(articleId, null);
articleId = '';
}
I'm writing above code to mass Archive articles.Bu its throwing below error
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.
String articleId = '';
hrlist=[SELECT ArticleType,Id,KnowledgeArticleId,Language,PublishStatus FROM KnowledgeArticleVersion WHERE ArticleType = 'How_To_HR__kav' AND Language = 'en_US' AND PublishStatus = 'Online'limit 100];
for(KnowledgeArticleVersion hr:hrlist)
{
articleId = hr.KnowledgeArticleId;
KbManagement.PublishingService.archiveOnlineArticle(articleId, null);
articleId = '';
}
I'm writing above code to mass Archive articles.Bu its throwing below error
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.
your code worked for me, can you archive articles manually?
also, your your code could be shortened a little, try this