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
SeanSeeSeanSee 

Prevent Going Backwards in a Picklist

I am trying to write a validation rule that will prevent users from going back to 'Sent' as a campaign member status.  I have rule but it is preventing the status from changing From 'Sent' and I need it to prevent users from going back to 'Sent'.  Can anyone please help.  The code is below

 

AND(ISCHANGED(Status),
NOT(ISPICKVAL(Status,"Sent")))

 

Thanks,


Sean

Steve :-/Steve :-/

You need to use a PRIORVALUE function in your VR 

SeanSeeSeanSee

Okay so I  tried adding prior value and it allows me to change away from 'Sent' but once it is changed I am not able to change back to any other status.  However, the only status that should not be able to be selected is 'Sent'.  Right now the validation rule reads

 

AND(ISCHANGED(Status),
NOT(ISPICKVAL(PRIORVALUE(Status),"Sent")))

 

Am  just going about the statement logic completely wrong?

Steve :-/Steve :-/

Here's one I wrote to prevent a Picklist from being rolled back

 

OR (
AND (
ISPICKVAL(Picklist_2__c, "3"),
ISPICKVAL(PRIORVALUE(Picklist_2__c),"1")),
AND (
ISPICKVAL(PRIORVALUE(Picklist_2__c),"4")),
OR (
ISPICKVAL(Picklist_2__c, "1"),
ISPICKVAL(Picklist_2__c, "2")))

 

 

SwarnasankhaSwarnasankha

If I understood your requirement correctly, you would like to ensure that the picklist value 'Sent' can be selected only once in the entire lifecycle of the record. If Yes, then try the following approach:

 

 

  1. Create a checkbox and name it as 'Sent Flag'. Use a workflow to set 'Sent Flag' as True when the value of the picklist is set to 'Sent'. While creating the Worfklow, please ensure that you select the Evaluation Criteria as 'When a record is created, or when a record is edited and did not previously meet the rule criteria'.
  2. Create a Validation rule with the following expression as the Error Condition Formula:

 

 

AND
(
  ISCHANGED(Status),
  ISPICKVAL(Status, "Sent"),
  Sent_Flag__c = True
)
This would work well for any new records or records whose Status has never been set to 'Sent' before; however, for existing records whose Status has been set to Sent or is currently set to Sent, the flag will need to be updated manually.