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
Alan_RuanAlan_Ruan 

change Idea status base on vote

Dear Expert.

I need to change Idea status base on number of Vote. I'm new to Apex, could you please advise why my code is not working?

trigger updateStatusbyVote on Idea (before update,before insert) {
for (Idea updatedIdea : Trigger.new) {
       if (updatedIdea.VoteTotal > 10) {
        updatedIdea.Status = 'Voted';
       }
}
}
sandip bijlwansandip bijlwan
Hi,

Status would be changed to 'Voted' when if condition matches. The code will work fine,
Alan_RuanAlan_Ruan
Thank you for the update. I tested but it doesn't work. I try to use system.debug to output the value for updatedIdea.VoteTotal but the output is null. Could you please advise? Thanks, Alan Ruan