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
Robin ShiraRobin Shira 

How to assign cases to article automatically in knowledge base.

I want to assign my case to article automatically is there any way to assign.

 please help
Thanks in advanced
Raj VakatiRaj Vakati
Refer this links 

https://help.salesforce.com/articleView?id=knowledge_caseclose_apex.htm&type=5
https://help.salesforce.com/articleView?id=entitlements_auto_add.htm&type=5

 
public class AgentContributionArticleController {
    // The constructor must take a ApexPages.KnowledgeArticleVersionStandardController as an argument
    public AgentContributionArticleController(ApexPages.KnowledgeArticleVersionStandardController ctl) {
        SObject article = ctl.getRecord();   //this is the SObject for the new article. 
                                             //It can optionally be cast to the proper article type, e.g. FAQ__kav article = (FAQ__kav) ctl.getRecord();
        
        String sourceId = ctl.getSourceId(); //this returns the id of the case that was closed.
        Case c = [select subject, description from Case where id=:sourceId];
        
        article.put('title', 'From Case: '+c.subject);  //this overrides the default behavior of pre-filling the title of the article with the subject of the closed case. 
        article.put('Details__c',c.description);  
        
        ctl.selectDataCategory('Geography','USA');  //Only one category per category group can be specified.
        ctl.selectDataCategory('Topics','Maintenance');                        
    }

 
Robin ShiraRobin Shira
Hi Raj,
Thanks for the help.
Is there any other way..