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
RamzRamz 

How to unlock records in apex code?

Hi,

Is it possible to unlock records that are submitted for approval in apex code? or is it possible to unlock records that are submitted for approval when logged in as delegated administrator. Please provide more details.

Thanks.

   

NBlasgenNBlasgen

I see an open suggestion from 2008 for the same feature.  Guess they haven't had a chance to do something like that yet.  I also looked at doing it via a Trigger (and firing the trigger via Apex) but I didn't have any luck on that.  So, at least from my view, I see no solution.  Didn't see anything in the API either.

Danny SalvadoriDanny Salvadori

Old news now, but this can be done using the Approval class.

 

if (Approval.isLocked(myRecord.Id)) {
	Approval.unlock(myRecord);
}
 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_approval.htm