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
RSuzukiRSuzuki 

Is there a way to retrieve Lightning Knowledge case suggested articles programmatically?

In Lightning Service, you can use the Knowledge component and turn on article suggestion on a case which will list a number of relevant articles. Is there a way to programmatically retrieve this list of suggested articles on a case using Apex or Lightning component? (I'm even open to REST or other APIs.) 
AbhishekAbhishek (Salesforce Developers) 
Hi Suzuki,

Yes, you can retrieve article content from Salesforce via the REST API but the method is not very straightforward. This is related to the fact that all articles are versioned. This means that the article ID is separate from the ID of the currently published version of that article (master ID). This master ID is what you need to query for if you want the article content.

Below is an example of fetching article content:

First, you have to fetch the master ID for the article:

// Request 
services/data/v29.0/knowledgeManagement/articles/{article-id}

// Result (truncated to for simplicity)
{
  …
  "draftArticleMasterVersionId": "am0k000000000HmAAB",
  "onlineArticleMasterVersionId": "am0k000000000HmAAA"   // <-- Master ID
  ...
}
Then use the master ID to obtain the article content via your article sobject:

Note: This will be API name of whatever you chose to name your Article Type in salesforce (Setup > Customize > Knowledge > Article Types). In my case my article type label is Knowledge Base so the sobject is "Knowledge_Base__kav"
// Request
services/data/v29.0/sobjects/Knowledge_Base__kav/am0k000000000HmAAA

// Result (truncated to for simplicity)
{
  "Title": "How to do some action",
  "Summary": "This article show you how to do some action",
  "ArticleNumber": "000001260",
  "Description__c": "Example article description on how to do some action"
}


Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Regards,
Salesforce Support.
RSuzukiRSuzuki
Hi thanks for the response. This however doesn't answer the question that I had of programmatically retrieving the list of suggested articles on a case. I can retrieve Knowledge__kav using SOQL or SOSL. But I'd like to know if there's a way to retrieve the Salesforce Recommended article on any given case that you can see with the Knowledge Lightning Component that comes with Service cloud. 
AbhishekAbhishek (Salesforce Developers) 
RSuzuki As of there is no suggested Article or working scenario.