function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Btuitasi1Btuitasi1 

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}"/>
                   </apex:form>


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;
}



}
}



 
Btuitasi1Btuitasi1
I've been using this as a reference for the Vote object
http://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_vote.htm
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.

Regards,
Praful G.