You need to sign in to do that
Don't have an account?

Unlock record from apex
I am trying to unlock the records locked from approval process using apex. I am trying to do it in the After Update context. Can I update same record in after update context?
Here is my sample code
I am using handler classes and calling this method from the handler class.
Thank you.
Here is my sample code
public static void unlockApprovalLockedRecords(list<customObject> records){ for(customObject sp : records){ if(Approval.isLocked(sp.id)) Approval.unlock(sp.id); }
I am using handler classes and calling this method from the handler class.
Thank you.
If you are getting System.NoAccessException then you need to follow bellow steps in your org:
Go to
Setup > Create > Workflows and Approvals > Process Automation Settings
And mark the checkbox Enable record locking and unlocking in Apex as true and save.
To update in after Update, you have to query the record/s from the database and then perform action on that record/s and do Update DML on these.