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.

1
  • how you want to select this specific sales manager, is that a lookup to User on that specific object? Dec 29, 2016 at 23:12

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .