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

Picklist Validation?

Hello, I am trying to validate a picklist. I would like the users to only be able to select the next value in the list.





Stage 1

Stage 2

Stage 3

Stage 4


I only want the user to be able to select "stage 1" save the record, The only be able to select "Stage 2" save the record... ect..  Is this possible?




If this is possible via a validation rule, it will be long, complicated, difficult to troubleshoot.


You should be able to do this fairly easily with a trigger.  The following is air code; I did not actually try to compile it but it should get you started.



trigger CustomObjectTrigger on CustomeObject__c (before insert, before update) { for (Integer i = 0; i <; i++ ) { if (Trigger.isInsert) if ([i].Stage != 'Stage 1')[i].Stage.AddError('Must Be created Stage 1'); if (Trigger.isUpdate) { if ((Trigger.old[i].Stage == 'Stage 1') && ([i].Stage != 'Stage 1' &&[i].Stage != 'Stage 2')[i].Stage.AddError('Must Create Stages in Order'); etc, etc, etc } } }





Thank you very much for your reply. I have taken a look at your code but i'm new to SF, could you let me know where I would apply this?



[Setup][App Setup][Create][Objects] Pick the object with the Stage field.  Scroll down to the triggers section and hit New.
I have naviagted there but I dont have any option to create a new triger. All I get is "No triggers defined" 
I'm just guessing here, but you're probably logged in as user whose profile does not have the 'Author Apex' checkbox checked under Administrative permissions.  If that's not it I'm clueless.