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
jeroenjeroen 

Help custom controller

Hello,

 

I am trying to create a page where users are able to vote to go on with a project or not. I looked at ideas, but that doesn't cover it for us.

So I am trying to make it myself. I have made a custom object Vote with a master-detail towards projects.

People are also able to make comments without voting, however they are only allowed to vote once! This is where the problem hits.

There is a picklist vote__c with the options None, Yes, No. If that user has made an earlier entry Yes or No he/she must not be allowed to vote! So in this case a boolean Able-vote (or something) must be set to false. So I can use this in the apex code!

 

I have not much experience with custom controllers, hope to in the future.

 

Thanks

Jeroen

Sam.arjSam.arj
I suggest to use the object where you maintain the results of votes.

example:
 ProjectVote object has the following fields:
  1. ProjectId
  2. UserId
  3. VotePickList
When a user loads your Vote Visualforce page, do a little SOQL to find out if the user have his vote in already or not, if yes take away the voting option and just show want his vote was or you may want to allow the user to change his/her opinion... whatever your requirement is.

Code:
ProjectVote VoteHistory = [Select id, ProjectId, UserId, VotePickList from ProjectVote 
where UserId = :userid limit 1]

 

jeroenjeroen

Hi Sam,

Thanks, I will give this a try! Might get back to you.

Jeroen:smileyvery-happy: