-1

Today I have to create a validation rule on an object:

one of it's field is a checkbox, and I want that if the checkbox is "true"

then a specific user (called A) must complete all the phases of the object

(Example: object has a many months, if a checkbox is "true" than the users must complete all the months, otherwise he can step from a month to another)

Thank you in advance.

Edit: if the checkbox of a field of object "Opportunity" is "true", the user MUST follow in CHRONOLOGICAL ORDER all the steps defined by field "status" (picklist with values: phase1, phase2, phase3, phase4)

8
  • Please clarify more on what should happen when the checkbox is true. It is not clear from the question Jun 30, 2022 at 9:31
  • what are all the fields(specify with data types) should fill by the user when checkbox is true. Jun 30, 2022 at 10:24
  • if checkbox=True in a field in object Opportunity, the user MUST follow in chronological order all the steps (field name: Status, defined by a picklist )
    – MashaMasha
    Jun 30, 2022 at 10:34
  • Can you explain the chronological order of status picklist in your case? Jun 30, 2022 at 10:43
  • phase1, phase2, phase3, phase4
    – MashaMasha
    Jun 30, 2022 at 10:44

1 Answer 1

0

Your validation rule should be like below.

Replace the field API names (Status1__c,Status_Order_check__c) as per your org.

Here, I am checking current user($User.Alias ='aband') based on Alias because we can't able to refer the Name field in the validation rule.

    AND(Status_Order_check__c=true, $User.Alias ='aband',
    ISCHANGED(Status1__c),  
    OR(AND(ISPICKVAL(PRIORVALUE(Status1__c),""),
         OR(ISPICKVAL(Status1__c,"phase2"), 
            ISPICKVAL(Status1__c,"phase3"),
            ISPICKVAL(Status1__c,"phase4"))),   
      AND(ISPICKVAL(PRIORVALUE(Status1__c),"phase1"),NOT(ISPICKVAL(Status1__c,"phase2"))
          ),
      AND(ISPICKVAL(PRIORVALUE(Status1__c),"phase2"),NOT(ISPICKVAL(Status1__c,"phase3"))
         ),
      AND(ISPICKVAL(PRIORVALUE(Status1__c),"phase3"),NOT(ISPICKVAL(Status1__c,"phase4"))
         )
    )  
)

AND

Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false.

Use the && (AND) function as an alternative to the operator.

Use: AND(logical1,logical2,...) and replace logical1,logical2,... with the values that you want evaluated.

PRIORVALUE

Returns the previous value of a field.

Use: PRIORVALUE(field)

|| (OR)

Evaluates if at least one of multiple values or expressions is true. Use: this operator as an alternative to the logical function OR.

Use: (logical1) || (logical2) and replace any number of logical references with the values or expressions you want evaluated.

1
  • Thank you so much, the explanation is perfect, have a good day
    – MashaMasha
    Jul 1, 2022 at 8:06

Not the answer you're looking for? Browse other questions tagged .