Check if a record is in approval process

I´m getting this Exception:

System.DmlException: Update failed. first error: ENTITY_IS_LOCKED, the entity is locked for editing:

The problem is that i´m updating a case that is locked by an approval process.
I want to add a check in my APEX controller, in order to update the record only if not in an approval process.

How i can accomplish that?


From Winter16 you can check this using the Approval system class

Pass it the Id of a record you want to check if is locked or not:


Make sure you set the class api version to 35.0 or higher!

Source : Link , Question Author : Enry , Answer Author : sskular

Leave a Comment