You need to sign in to do that
Don't have an account?
RSuzuki
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.)
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.