Posted in Salesforce

Allow other users to unlock record in approval process

Lock() and unlock() methods in the System.Approval Class let you lock and unlock records by passing in record IDs or sObjects.

Enable the feature by :-
Setup –> Process Automation Settings –> Enable record locking and unlocking in Apex.

Create a Detail Page Button and associate it with the Visualforce Page and place it on the Page Layout. 

Create a Visualforce Page

<apex:page standardController="Order" extensions="OrderLockUnlockController" action="{!unlock}">

Create a Class

public class OrderLockUnlockController{
     private Id recId;

     public OrderLockUnlockController(ApexPages.StandardController stdCtrl) { 
         recId = stdCtrl.getId();

     public PageReference unlock(){
         if (Approval.isLocked(recId)) {
         PageReference pageRef = new PageReference('/'+recId);
         return pageRef;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s