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
Elton dos Santos 4Elton dos Santos 4 

Validation Rule with Status Case

Hi everyone, can you help me with a rule?

I have a validation rule with 6 level, and I can't to jump this steps, except to the last step(closed). For exemplo: Step 1 to 2 or step 1 to 6 , but step 1 to 3 or 1 to 4 can not. Look how is my code now.

AND
(
    RecordType.DeveloperName = 'test',
    CASE(Status, 
        "step 1",1,
        "step 2",2,
        "step 3",3,
        "step 4",4,
        "step 5",5,
        "Closed 6",6,
    0) 
    !=  
        (CASE(PRIORVALUE(Status), 
        "step 1",1,
        "step 2",2,
        "step 3",3,
        "step 4",4,          
        "step 5",5,
        "Closed 6",6,
    0) + 1)
)

Best Answer chosen by Elton dos Santos 4
Alain CabonAlain Cabon
Hi,
 
NOT(CONTAINS ("step 1|step 2|step 3|step 4|step 5|Closed", TEXT(PRIORVALUE(Status)))) 
&& TEXT(Status) = "Closed"
|| TEXT(Status) != "Closed" 
&& CASE(Status, 
        "step 2",2,
        "step 3",3,
        "step 4",4,
        "step 5",5,
    1) 
    !=  
        (CASE(PRIORVALUE(Status), 
        "step 1",1,
        "step 2",2,
        "step 3",3,
        "step 4",4,          
    0) + 1)

But this rule doesn't prevent "Closed" to "step x".
 

All Answers

Alain CabonAlain Cabon
Hi,
 
NOT(CONTAINS ("step 1|step 2|step 3|step 4|step 5|Closed", TEXT(PRIORVALUE(Status)))) 
&& TEXT(Status) = "Closed"
|| TEXT(Status) != "Closed" 
&& CASE(Status, 
        "step 2",2,
        "step 3",3,
        "step 4",4,
        "step 5",5,
    1) 
    !=  
        (CASE(PRIORVALUE(Status), 
        "step 1",1,
        "step 2",2,
        "step 3",3,
        "step 4",4,          
    0) + 1)

But this rule doesn't prevent "Closed" to "step x".
 
This was selected as the best answer
Elton dos Santos 4Elton dos Santos 4
Hi Alain Cabon, Thanks for your answer.

This rule doesn't worked. Maybe I did had explained wrong.

I have 6 stage of the case, and I just can jump one after other, never two or more, except to close the case. In any step I can goes to the last(In this case to close my case).

I should identify the recortype, because I have others type to aplicate in the same rule.

do you understand me?
 
Alain CabonAlain Cabon
Hi,

That doesn't work for what step exactly?  The recordtype is not the problem but you must keep it on your org indeed (I don't have your recordtype).

Your problem was the "Closed" step.

"Closed" is always possible ( step1,2,3,4,5 > Closed: ok) so you must use my method.

step 1 > step 2 > step 3 > step 4 > step 5 : ok

step 1 > step 3 or 4 or 5 : ko

step 2 > step 1 or 4 or 5 : ko

The remaining problem is to lock (or not) the "Closed" step. Not blocked with the code above but it is easy to block the last step.

Your problem is very simple.
Elton dos Santos 4Elton dos Santos 4
Hi Alan,

Look my status in image below: 

User-added image
I cant to jumper from Pending > MTO or Pending > Report or Pending > Review, I always  have to jump step by step, exception to closed stage. I alwery can to jump to the closed stage.

In your exemplo I can to go to "closed", it ok, but is jumping steps.
SEKAR RAJ.SEKAR RAJ.
Hi Elton,
Try this ;

AND
(
    RecordType.DeveloperName = 'test',
    CASE(Status, 
        "step 1",1,
        "step 2",2,
        "step 3",3,
        "step 4",4,
        "step 5",5,
        "Closed 6",6,
    0) 
    >
        (CASE(PRIORVALUE(Status), 
        "step 1",1,
        "step 2",2,
        "step 3",3,
        "step 4",4,          
        "step 5",5,
        "Closed 6",6,
    0) + 1)
)

Thanks,
SEKAR RAJ