I am developing a test Class for a Controller .To have a sufficient test coverage I want to create ArticleTypes (_KAV) via Apex.
Is this possible ,if so then how to accomplish this?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
My understanding is that a dedicated sObject will be available for each Article Type. It will follow the format
<ArticleType>__kav for the KnowledgeArticleVersion. If your article type was
FAQ then you could create a an instance as follows:
FAQ__kav testFaq = new FAQ__kav(); testFaq.Title = 'Test FAQ'; testFaq.Summary = 'KB Summary'; testFaq.URLName = 'test'; insert testFaq; // Get the KnowledgeArticleId FAQ__kav insertedTestFaq = [Select KnowledgeArticleId from FAQ__kav where ID = :testFaq.Id]; // Publish KbManagement.PublishingService.publishArticle(insertedTestFaq.KnowledgeArticleId, true);