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
Shubhangi JadhavShubhangi Jadhav 

Trigger on order for status to check

Old:Status <> new:status and Old:Status = Cancelled then stop saving of record

I need to compare value and need to stop by saving the record
Best Answer chosen by Shubhangi Jadhav
RituSharmaRituSharma
Please mark my answer as the best answer if it was helpful for you. This would help others in future.

All Answers

RituSharmaRituSharma
This can be easily achieved using validation rule. No need to write APEX.

You may use below formula in validation rule:
And(ISCHANGED(Status),ISPICKVAL(Status,"Cancelled"))
RituSharmaRituSharma
Please mark my answer as the best answer if it was helpful for you. This would help others in future.
This was selected as the best answer
Shubhangi JadhavShubhangi Jadhav
Hi Ritu,

Thank you for your response.but its not allowing to edit any other fields for this balidation on order fields.

Can you tell me how can i achieve this with trigger?

Regards,
Shubhangi
Shubhangi JadhavShubhangi Jadhav
Hi Ritu,

See what i have tried:
(ISPICKVAL(PRIORVALUE(Tet_Status__c),"Cancelled"))

Regards,
Shubhangi
RituSharmaRituSharma
If you want to stop user from changing any field then use my formula. If you want to stop user from changing just the status then use your formula. 
Shubhangi JadhavShubhangi Jadhav
with this formula..I am not bale to change any of the field on order header
(ISPICKVAL(PRIORVALUE(Tet_Status__c),"Cancelled"))