You need to sign in to do that
Don't have an account?

Cannot move Published article to draft via apex.
Hi Everyone,
When I try to move published article to draft using this code ,
String str =KbManagement.PublishingService.editOnlineArticle('kAA4C000000CaTmWAK', true);, it throws following 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.
I'm runing this code as system admin who have "Manage Article Permission".
Can you guys get me a solution for this.
Thanks,
Vignesh.B
When I try to move published article to draft using this code ,
String str =KbManagement.PublishingService.editOnlineArticle('kAA4C000000CaTmWAK', true);, it throws following 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.
I'm runing this code as system admin who have "Manage Article Permission".
Can you guys get me a solution for this.
Thanks,
Vignesh.B
sorry for this issue you are facing.
May I suggest you please double check with the following permissions is any one of them might be missing.
- To create articles: “Manage Articles” AND "Create” and “Read” on the article type
- To edit draft articles: “Manage Articles” AND “Read” and “Edit” on the article type
- To edit published or archived articles: “Manage Articles” AND “Create,” “Read,” and “Edit” on the article type
They also have Article Actions under Setup for Edit Published and Archived Knowledge Articles, which is set to ALLAlso, could you please confirm what you have in "string str"? because edit online article will take the parameter article ID as string ID.
Happy to help further.
Please let us know if this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
1.You dont have knolwedge User Checked on your user .From your description of problem I am ruling this out since you say from UI you are able to do this .But just double check your user record to see if knowledge User is checked
2.Ensure proper permissions like
“Manage Articles” (This permission is on by default in the System Administrator profile.)
AND
“Read”, “Create”, and “Edit” on the article type
AND
A publish or archive article action, set on the Article Actions Setup page
Also note that if one of records fail in your code ,all the records fail ,try doing with hardcoded Id first one by one
KBManagement.PublishingService.editOnlineArticle('put your harcode Id once',false);
Hi Vignesh,
You received this error because you are using not correct Id. Try to use KnowledgeArticleId, not a Knowledge__kav.Id.
You can find more details here (https://salesforceprofs.com/updating-knowledge-articles-programmatically-by-apex/).
Regards,
Piotr
We are running into same issue. We checked all the permissions. And we are passing the right KA id. Interesting thing is, the exact same logic works for some articles of same type. Is there anything else we are over looking?
Hi Mitesh,
It can have a few causes:
3. Each time when you invoke KbManagement.PublishingService.editOnlineArticle => KnowledgeArticleId is changing.
If it still doesn't work please give me more details (like code snippet, article PublishStatus), I will try to help.
Thanks for quick response. I think we may be running into "one or more of those online article already has a draft article" issue mentioned here: https://salesforce.stackexchange.com/questions/115592/mass-updating-published-articles
Here is the code snippet
You are using 18 digit code(Salesforce Id) to edit it because of that it will get that error please make 15 digit code (Salesforce Id), It will work.
I have same problem but now working good.
Thanks,