function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Giacomo DorandiniGiacomo Dorandini 

Delete Knowledge Article Version with Apex


I'm trying to delete a knowledge article version record using apex, in details what I try to do is:
        string t = (string that holds the Id of the article)
        KnowledgeArticleVersion articleToRemove = [SELECT Id FROM KnowledgeArticleVersion WHERE Id = :t];
        delete articleToRemove ;

When I try to save the class I recieve the following error message:
DML operation DELETE not allowed on KnowledgeArticleVersion

Same error messagge if I use the article type insted of KnowledgeArticleVersion (FAQ__kav articleToRemove = [SELECT Id FROM FAQ__kav WHERE Id = :t])
Any suggestion? I found this in the documentation 
  • To create, update, or delete a Knowledge article version, use the call on ArticleType_kav, where ArticleType is the name of the article’s type. For example, to delete use ArticleType_kav.delete(). (see
but I don't know how to use it.
Thank you for your help.
PratikPratik (Salesforce Developers) 
Hi Giacomo,

Are you trying to delet the articles which are online?
Try the articles which are either archived or draft stage.

Giacomo DorandiniGiacomo Dorandini
Hi Pratik,

thank you for your answer. The article I'm trying to delete is in Draft status. Any suggestion?

PratikPratik (Salesforce Developers) 
Hi Giacomo,

I tried thi on developer console:

string t = ('18_digit_id_of_article')
 FAQ__kav articleToRemove = [SELECT Id FROM FAQ__kav WHERE Id = :t]
 delete articleToRemove ;

After this also it's showing that:
"DML operation DELETE not allowed on FAQ__kav"

So Articles can be archived and not deleted.

Hi Giacomo, 

Try this 

String articleVersionId = 'Insert article ID';
KbManagement.PublishingService.deleteDraftTranslation (articleVersionId);

Important :

If you have received the answer which you are looking for, Please mark it as a Solution, this will help others to find the resolution of problem with ease. More, you can make the Developers of the Community smile by appreciating the answer with the "Like" Button. We would love to help you again. 

Thank You
Gautam Singh 
Blog -
Me   -