+ Start a Discussion

Idea voting extension on VF page

I'm trying to use custom buttons to set the Vote object as "Up" or "Down". I have the buttons up, but I'm having trouble with the beginning part of the extension. I am still fairly new to apex.

Any help would be appreciated!

VF Page Sample
<apex:form >
                   <apex:commandButton styleclass="btn-lg btn-data" value="Vote Up" action="{!setValue1}"/>
                   <apex:commandButton styleclass="btn-lg btn-data" value="Vote Down" action="{!setValue2}"/>

Extension so far
public class detailExt{
public myControllerExtension(ApexPages.StandardController stdController) {
         public Vote setVote {get; set;}

public void setValue1() {
    setVote.Type = 'Up';
    setVote.ParentId = Idea.Id;
public void setValue1() {
    setVote.Type = 'Down';
    setVote.ParentId = Idea.Id;


I've been using this as a reference for the Vote object
Praful GadgePraful Gadge
Hi Brother!

I think you need to insert Vote record after setting Type and Parent id. Can you please try to insert setVote on the next line of setvote.ParentId = Idea.Id;

Please try and let me know if you still face any issue.

If this post is your solution, kindly mark this as the solution to the post so that others may benefit.

Praful G.