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
Anuj Thakur 4Anuj Thakur 4 

i have one status field which is picklist type.

I have a picklist field called Status. Picklist values are [A,B,C,D,E]. lets suppose status picklist value is "A".Now if user can select only
B means user always can select A to B, B to C, C to D etc. they can not select A to C or C to E. so how we can implement it using triggers?
Also, the solution should work if any new value is deleted or added to Status field in future like "F" or G etc
Any suggestion is highly appriciated!!
Thanks in Advance.
Chanchal

Raj VakatiRaj Vakati
You can do it as below .. 

Create a custom formula  field that will return your org 
 
IF(TEXT(Status) = "A", 1,
IF(TEXT(Status) = "B",2,
IF(TEXT(Status) = "C", 3,
IF(TEXT(Status) = "D", 4,
NULL
))))

Create a validation rule to check the next value sholud be less than one or grater than one