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
Jyosi jyosiJyosi jyosi 

Validation Rule Help on Case status

Hello Everyone,

I was having hard time to build the Valiadtion rule on Case status field.

User creates a record with status "New and they save records and again they can come over and change the status to Ready"  from interface the fields get updated to "Sent" once the status has values sent i am not supposed to allow the user to chnage the status values from case deatil page

Thanks

Regards,
Jyo
Tugce SirinTugce Sirin
IF( ISPICKVAL( PRIORVALUE(Status) , 'Sent'), IF( NOT(ISPICKVAL(Status, 'Sent')) , true, false) , false)

I think this will work for you. Let me know if this helps.
Shalagha GumberShalagha Gumber
Jyosi, what I understand from your query above is: You need a validation rule that gives an error if the User edits the Status (when Status=Sent) from UI but if the Status is changed from code, it must not throw the validation error.

If this is the case, you can create a flag in the code-isStatusChangedFromCode, set it to true if any functionality in the code updates the Status. So this flag will be false if a user tries to update the status from the Case Detail page. The same flag can be used in the validation rule (that can be written in the code) to track whether the Case update request came from Apex or UI.

But this solution only works if all the Status update logics are written in the code. If there is any workflow rule that updates Case Status, you might have to figure out something else.

Thanks.