0

I am writing one validation rule where status is Pending/In Progress and I am changing any value from record then I need to throw an error 'you cannot edit the record'.

AND(OR( ISPICKVAL( Status , 'Pending'), 
ISPICKVAL( Status , 'InProgress'))

The issue here it's not allow me to set status Pending at all..then i Added

OR( AND( ISPICKVAL(PRIORVALUE(Status),"Pending"),ISPICKVAL( Status , 'Pending')), 
 AND( ISPICKVAL(PRIORVALUE(Status),"InProgress"),ISPICKVAL( Status , 'InProgress'))) 

Again the issue is when I Set status from suppose Review to Pending then it will save. which is correct, and then if I try to edit record then it will be thrown an error. but when I am changing the value from Pending to something else like Complete then it should not be thrown an error, but because of PRIORVALUE() its throwing error.

Please suggest

  • Your second validation rule look corrects to me. – Tushar Sharma Feb 4 '19 at 7:09
0

Your second validation rule should suffice your needs.

But if it's still giving you an error, then can you check

  • If you have any triggers on that object
  • If Yes, then check if you are updating the status back to Pending/InProgress in your before insert/update code

If the answer for above two questions is Yes, then that might be the reason you are getting that error from validation rule.

|improve this answer|||||
1

you want to add exception, that you can change Status from InProgress to Pending:

OR(
    AND(
        ISPICKVAL(Status  'Pending'),
        NOT(ISPICKVAL(PRIORVALUE(Status),'InProgress'))
    ),
    ISPICKVAL(Status , 'InProgress')
)
|improve this answer|||||
  • but here when i am changing value from Pending to some other then it should save – sudhanshu Feb 4 '19 at 7:21
  • @sam can you formalize your validation rule ? e.g prevent from editing record, once Status= 'pending' or Status='InProgress' or.... but allow to change status at any time. – Oleksandr Berehovskyi Feb 4 '19 at 7:25
  • not yet.facing issues on above validation – sudhanshu Feb 4 '19 at 8:34

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.