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
LeeCLeeC 

Picklist order

Hello all,

 

Is it possible to have a picklist with say A, B, C, D values. The first time a user edits the record the picklist displays value A & B, If the user changes the value to B and edits the record they can now see B, C. Again once the user edits the record and changes the value to C, they can now see C and D.......

 

Does anyone know if this is possible and how I would go about setting this up?

 

Thanks,

 

Lee

werewolfwerewolf
Not really.  You're saying that once you change the picklist, your old value goes away?  What is the actual use case for that?  What if he mistakenly picks B and then wants to get back to A -- he can't?!?
LeeCLeeC

I want to make it so the use has to follow an order. i.e. A -> B -> C -> D. There would be no reason for the user to ever need to go back to a previous value.

werewolfwerewolf

Unless he saves by mistake.

 

You can't really hide "old" picklist items, unless you want to do lots of machinations with record types (which will get messy quickly), but you can make a validation rule that prevents the user from going back.  That's probably your best bet.  Or you can write a Visualforce page with a picklist that you fill with values as you see fit -- then you can do whatever you want.

LeeCLeeC

How would I create the validation rule which would stop the user going back? could you give me an example please 

 

Thanks,

 

Lee

werewolfwerewolf

It's not short and it gets bigger depending on how big your picklist is.  If you name things in the picklist strategically, though, it gets easier.  Let's say your picklist is a status picklist, and you name its values like:

 

01 - Prospecting

02 - Qualified

03 - Negotiating

04 - Closed

 

Then you can make a fairly simple validation rule like

 

VALUE (LEFT (TEXT( PRIORVALUE (P1__c) ), 2 ) ) < VALUE (LEFT (TEXT( P1__c), 2 ) )

 

which compares the value of the number on the left side to the formerly selected value of that number.

LeeCLeeC

Thank alot for that. I just have one question though. what happens if the user was on 03 - Negotiating, then they try and save the value as 01 - Prospecting. This will allow them to save the record as the previous value would have been 02 - Qualified? Will it only check againt the prior value not all prior values?

 

hopefully that makes sense

werewolfwerewolf
It won't check against all prior values, but if this validation rule is in effect you're guaranteed that all prior values will be less than the current value.  Trust me, this formula will work for you.
werewolfwerewolf
Oh, I see, you are not understanding what PRIORVALUE does.  If the user is currently on 03 - Negotiating and he attempts to change it to 01 - Prospecting, then the PRIORVALUE = 03 - Negotiating and the "current" value (at least for the purposes of this validation rule) is 01 - Prospecting.  Since 01 < 03, this validation rule will fire and prevent the edit, restoring the value to its "prior value," namely 03 - Negotiating.