[SalesForce] Where does like & dislikes stores when we give knowledge article feedback

When we open any knowledge article in community then at the bottom we have an option like Was this article helpful? So when we click on like or dislike then on which object that count stores.

I want to create a custom lwc for article feedback so, I need to insert those voting records using apex. But don't know where does it stores.

Best Answer

I'll break this up as I answered a different couple things for inserting a vote in apex, pulling the vote stats for an article, and for getting a normalized score of the article votes.


Insert a vote record

There's a Vote object you'd need to interact with and set the ParentId to the knowledge article. The Knowledge Object Model below indicates this.

enter image description here

The Salesforce Knowledge Developer Guide is your friend here and you'll see the model I pasted above. It's important to note, based on this answer, that each user can rate an article only once.


Pulling the vote stats through REST API. Going again off the same developer guide, you can do the following:

/services/data/v38.0/support/knowledgeArticles?sort=ViewScore&channel=Pkb&pageSize=3
HTTP Headers:
Content-Type: application/json; charset=UTF-8
Accept: application/json
Accept-Language: en-US

This will return an output like so where you can see upVoteCount and downVoteCount:

{
"articles" : [ {
"articleNumber" : "000001002",
"categoryGroups" : [ ],
"downVoteCount" : 0,
"id" : "kA0xx000000000BCAQ",
"lastPublishedDate" : "2015-02-25T02:07:18Z",
"summary" : "With this online Chinese input tool, you can type Chinese characters
through your web browser without installing any Chinese input software in your system.
The Chinese online input tool uses the popular Pin Yin input method. It is a fast and
convenient tool to input Chinese on English OS environments.",
"title" : "Long text test",
"upVoteCount" : 0,
"url" : "/services/data/v38.0/support/knowledgeArticles/kA0xx000000000BCAQ",
"viewCount" : 4,
"viewScore" : 100.0
}, {
"articleNumber" : "000001004",
"categoryGroups" : [ ],
"downVoteCount" : 0,
"id" : "kA0xx000000000LCAQ",
"lastPublishedDate" : "2016-06-21T21:11:02Z",
"summary" : "The number of characters required for complete coverage of all these
languages' needs cannot fit in the 256-character code space of 8-bit character encodings,
requiring at least a 16-bit fixed width encoding or multi-byte variable-length encodings.
\r\n\r\nAlthough CJK encodings have common character sets, the encodings often used to
represent them have been developed separately by different East Asian governments and
software companies, and are mutually incompatible. Unicode has attempted, with some
controversy, to unify the character sets in a process known as Han unification.\r\n\r\nCJK
character encodings should consist minimally of Han characters p",
"title" : "Test Images",
"upVoteCount" : 0,
"url" : "/services/data/v38.0/support/knowledgeArticles/kA0xx000000000LCAQ",
"viewCount" : 0,
"viewScore" : 0.0
}, {
"articleNumber" : "000001012",
"categoryGroups" : [ ],
"downVoteCount" : 0,
"id" : "kA0xx000000006GCAQ",
"lastPublishedDate" : "2016-06-21T21:10:48Z",
"summary" : null,
"title" : "Test Draft 2",

You can make this query per channel (notice the url request).


Reference

Pulling normalizedScore for Articles

It's under KnowledgeArticleVoteStat in the NormalizedScore field. It's not the raw stats as it's a normalized score based on the # of thumbs up/down and when those votes were cast.

enter image description here

Related Topic