Create a new article
Knowledge__kav ka = new Knowledge__kav(); ka.Title = 'Salesforce CRM'; ka.UrlName = 'salesforce-crm'; ka.Summary = 'Salesforce Cloud CRM'; ka.Language = 'en_US'; insert ka;
Publish a draft Article
String knowledgeArticleId = 'kA06g000002AJ7t'; //Add knowledge article record id KbManagement.PublishingService.publishArticle(knowledgeArticleId, true);
Set a schedule for archiving a published article
String knowledgeArticleId = 'kA06g000002AJ7t'; //Add knowledge article record id Datetime scheduledDate = System.now().addMonths(2); //Add date to schedule the archive KbManagement.PublishingService.archiveOnlineArticle(knowledgeArticleId, scheduledDate);
“Please be aware that if the scheduledDate is left blank or set as null, the article will be archived right away.”
Abort the scheduled archiving of a published article
String knowledgeArticleId = 'kA06g000002AJ7t'; //Add knowledge article record id KbManagement.PublishingService.cancelScheduledArchivingOfArticle(knowledgeArticleId);
Remove an article from the archived section
String knowledgeArticleId = 'kA06g000002AJ7t'; //Add knowledge article record id KbManagement.PublishingService.deleteArchivedArticle(knowledgeArticleId);
Delete a draft article
String knowledgeArticleId = 'kA06g000002AJ7t'; //Add knowledge article record id KbManagement.PublishingService.deleteDraftArticle(knowledgeArticleId);
Generate a draft article using content from an archived article
String knowledgeArticleId = 'kA06g000002AJ7t'; //Add knowledge article record id KbManagement.PublishingService.editArchivedArticle(knowledgeArticleId);
Deactivate a published article
String knowledgeArticleId = 'kA06g000002AJ7t'; //Add knowledge article record id KbManagement.PublishingService.editOnlineArticle(knowledgeArticleId, true);