The enforcement of stage progression is most easily done using validation rules with the ISCHANGED
and PRIORVALUE
functions. The validation rule will enforce stage progress based on the current and prior picklist value.
This example validation rule should enforce the progress from Draft
to Rep Input
to Rep Ack
to Completed
and nothing is allowed to be reverted back to Draft
status. (The first AND
from "not draft" to "draft" might need to be altered to handle a blank value, but it demonstrates the idea.)
As Mike noted in his answer, this methodology only forces the user to save the record multiple times with picklist values in a specific order - it doesn't truly enforce anything. Though maybe this is exactly what you're looking to do here.
One thing to note, this is not just a VF solution. It works in all cases - VF, native pages, data loader, batches, etc. since it's enforced at the record level when the database commit takes place.
Error Formula
AND(
ISCHANGED( Status ),
OR(
AND(
NOT(ISPICKVAL( PRIORVALUE( Status ), "Draft" )),
ISPICKVAL( Status, "Draft" )
),
AND(
NOT(ISPICKVAL( PRIORVALUE( Status ), "Draft" )),
ISPICKVAL( Status, "Rep Input" )
),
AND(
NOT(ISPICKVAL( PRIORVALUE( Status ), "Rep Input" )),
ISPICKVAL( Status, "Rep Ack" )
),
AND(
NOT(ISPICKVAL( PRIORVALUE( Status ), "Rep Ack" )),
ISPICKVAL( Status, "Completed" )
)
)
)
We just had the same problem with some clients, and after some digging it had something to do with the Spring 17 release.
Your browser caches assets from the server locally (javascript, css, ...), in Spring 17 a change was made to picklists.js, a javascript file responsible for filling picklist values. In some cases users still had the old javascript from before the release cached in their browser, and that old file doesn't work with the new way of filling picklist values.
The easy way to fix it is by clearing your local files. In chrome you can do this by following these steps:
- Open the page that doesn't show the picklist values
- Open Developer Tools (F12, or right mouse button somewhere in the page -> inspect element)
- Go to the Network tab
- On the top check the "Disable cache" checkbox
- Reload your page
- Uncheck the "Disable cache"
- Close developer tools
If a Salesforce developer reads this:
When your browser tries to load a page which loads a javascript file, it will look at the URL of the javascript file, and then look in the local cache if the javascript file for that URL is present. If so, for performance reasons, the javascript file from the cache will be loaded instead of the remote javascript file.
This can easily be solved by adding a fingerprint to the URL of the javascript file. For example:
<script src="myscripts.js?fingerprint=023UJKdlmamlsqdvNNKKl"></script>
The moment the javascript file is changed (with a new release or whatever), just change the fingerprint, and the file will be cached again locally. (It can be whatever parameter you want, as long as the SRC changes)
Best Answer
Im assuming your controller property to get the options looks something like one of the following
If you are taking the values directly from a specific picklist field
Or if you are manually adding the options, then something like this
If you want to adjust the options according to profile then you could simply do something like this