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.
There must be a very good reason why we complicated our lives with all these technologies ... arguably that is freedom for something. Freedom might be a right but it is never free; so let me demonstrate how I earned it.
Showing posts with label Visualforce. Show all posts
Showing posts with label Visualforce. Show all posts
Monday, December 19, 2016
Friday, January 16, 2015
Enable Visualforce pages for Salesforce1
It's a fairly simple process. Barring any unsupported stuff on the VF, it should just work. However I've run in a timeout issue on more than one occasions - clicking on Save ended with a timeout page and the change was never saved. Had no idea why and didn't have the patience to open a case with Salesforce, so I took the developer route.
Here's how you can work around it if you can use developer tools (or any Metadata API enabled tool for that matter). The enablement switch is implemented as this availableInTouch field on the ApexPage object. All is needed is to flip it to true. For instance if you have Eclipse, you'll notice the field as a member in the page-meta.xml file.
Quick code formatting provided by Source Code Formatter
Once flipped, save it (remember to Save to Server, as Eclipse doesn't build it to server for meta files) and you're all set. Similarly this can be done with Ant as well.
Please note the field is only available API 27 or later, so make sure the tool connects using supported API versions.
Here's how you can work around it if you can use developer tools (or any Metadata API enabled tool for that matter). The enablement switch is implemented as this availableInTouch field on the ApexPage object. All is needed is to flip it to true. For instance if you have Eclipse, you'll notice the field as a member in the page-meta.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>27.0</apiVersion>
<availableInTouch>false</availableInTouch>
<confirmationTokenRequired>false</confirmationTokenRequired>
<label>MyPage</label>
</ApexPage>
Once flipped, save it (remember to Save to Server, as Eclipse doesn't build it to server for meta files) and you're all set. Similarly this can be done with Ant as well.
Please note the field is only available API 27 or later, so make sure the tool connects using supported API versions.
Wednesday, February 2, 2011
Client side vs. server side on Visualforce
What I needed to do was to disable a drop down box based on the selection in another drop down. Fairly common requirement. The controller drop down starts as disabled, so I set disabled property in , and used JavaScript from onchange to toggle disabled in HTML DOM from the controlling drop down. All sounded fine and dandy and the UI worked as it should, until I realized that the form never returned anything from the controlled drop down no matter what its status was.
It looks like the client side JavaScript did nothing to enable the controlled element. As far as the server was concerned, it's a field it can discard. I didn't do any HTML/JS debugging to confirm that, but it certainly felt that way. Once I switched the controlling mechanism to server-side processing/AJAX, it started to work as intended.
The only drawback with the AJAX way was that it's a bit slower. Action from the client-side Javascript was instant. With AJAX and its server round trip, it took about one second for the controlled drop down to change status.
It looks like the client side JavaScript did nothing to enable the controlled element. As far as the server was concerned, it's a field it can discard. I didn't do any HTML/JS debugging to confirm that, but it certainly felt that way. Once I switched the controlling mechanism to server-side processing/AJAX, it started to work as intended.
The only drawback with the AJAX way was that it's a bit slower. Action from the client-side Javascript was instant. With AJAX and its server round trip, it took about one second for the controlled drop down to change status.
Subscribe to:
Posts (Atom)