6

How to force the order of execution(selection) of the picklist values in salesforce.Is there any other way other than validation rules in visualforce page.

Lets say I have 4 picklist values (Draft,Rep Input,Rep Ack,Completed) on Status field.I want to force the users to go through each stage before it gets to 'Completed' status.

The process is similar to opportunity stage

  • 1
    If you need control of what is surfaced to the user through the UI, then you need Visualforce. Visualforce really the best avenue for "native" interface UI control. – greenstork Nov 21 '13 at 17:21
6

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" )
        )
    )
)
| improve this answer | |
3

Validation rules could help, but the would not really be enforceable. A user could save the record as the next step and then keep updating the steps, one save at a time. This is more of a user training problem and not something the technology can solve.

| improve this answer | |
0

You can use a trigger, but it is worse than a validation rule. So validation rule is Ok.

I just can not understand why this is necessary. You can create Visualforce wizard to provide 4-step process. In this case, the user will not be able to skip any step. Instead, an administrator can create a record using APEX with Completed status.

| improve this answer | |
  • I cannot use visualforce wizard.My process is similar to Opportunity Stage – sfdc Nov 21 '13 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.