I'm using the standard idea object to post ideas and have users promote/demote ideas. How can you query an idea record to determine if a user has voted on the idea?
Thanks for any help.
You can use the Vote sObject. Your query might look something like this:
List<Vote> userVote = [SELECT CreatedById, ParentId FROM Vote WHERE CreatedById = :UserId AND ParentId = :IdeaId]
obviously replacing the Ids appropriately in the where clause. You could then check if this list's size is 0 or not to determine if a given user voted.
List<Vote> lstVote = [SELECT Type FROM Vote WHERE CreatedById =: UserId AND ParentId =: IdeaId];
This query will work , what is asked in question.