0

In our current approval process, once the user sends the record through to intial approval, the record is locked. There are limited times when the record needs to be unlocked and we'd like an end user to be able to do that.

Currently in our rules, it says the record editability is only allowed by the system admins. The only other option is "Administrators OR the currently assigned approver can edit records during the approval process." Instead of the "currently assigned approver," we'd actually like to change that to a specific sales manager. Does anyone know if that is possible?

As a system admin, I can see the "Unlock" button whenever a record is locked. We'd like this other user to be able to see this too and successfully unlock the record.

  • how you want to select this specific sales manager, is that a lookup to User on that specific object? – Santanu Boral Dec 29 '16 at 23:12
2

One way to do this would be through a VF controller, the Apex Approval class methods and a custom link or button bound to the VF page.

Controller

public class FooUnlockController {
     private Id fId;
     private ApexPages.StandardController ctlr;

     public FooUnlockController(ApexPages.StandardController ctlr) {  // constructor
       this.fId = ctlr.getId();
       this.ctlr = ctlr;
     }

     public PageReference unlock() {  // page action method
         if (Approval.isLocked(this.fId))
             Approval.unlock(this.fId);
         PageReference resPg = new PageReference('/'+this.fId);
         resPg.setRedirect(true);
         return resPg;
     }             
} 

VF page

<apex:page standardController="Foo__c" extensions="FooUnlockController"
      action="{!unlock}">
<apex:page>

Associate the VF page to a custom link or button on the standard page layout

And then give your special user(s) a Permission Set to this VF page; everyone else will get an access denied

Be sure to enable this feature by Setup | Process Automation Settings | Enable record locking and unlocking in Apex

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.