Monday, December 19, 2016

Thumbs Up/Down ("Solution Helpfulness Rating") Feature for Knowledge with Visualforce/Apex

This is a feature that came out without too much fanfare and was supposedly meant to address an idea.  The only place that mentioned how to use it in Salesforce with details was in Summer '15 Release Notes, when it came out as beta.  Then there's an article about using it with Community templates, in which it's referred as "Article Voting".  None of them gives any clue on how it can be used in a Sites based Public Knowledge Base, which happens to be the use case I need to handle. 

After some back and forth with Salesforce Support, they pointed me to this Developer Forum thread that talks about Vote object for Idea.  I did some simple code to verify, and I could indeed set parentId to __ka objects and programmatically manipulate up/down vote state.  That, was not mentioned at all in the official doc for the Vote object (as of Dec 2016, ver. 38.0).

With almost all the pieces in place, one hurdle remains for to a public KB Up/Down vote solution in VF/Apex, if the KB is used in an unauthenticated context.  Vote object doesn't allow vote on the same parentId more than once by the same user.  If the users are unauthenticated - basically always Public Site Guest User - then votes can't really be recorded for more than once.  That's hardly useful.  I have no workaround so far, other than building a custom solution without using Vote.  That would suck if you'd really want internal and external votes are counted and reported together.

No comments:

Post a Comment