Approval Processes: Unlock Records in Lightning

When a record is submitted into an approval process, it gets locked. Sometimes it’s desirable to unlock the record manually.

In Salesforce Classic, you do that via a button that shows up here:

This button is not currently available in Lightning Experience, but it’s easy to add a quick action button to a record page layout that unlocks locked records.

The quick action button will run the following Unlock Record flow, which includes two new Flow Actions: Unlock Record and Get Record Lock Status.

Get Record Lock status returns a boolean value that tells whether a provided record is locked. Unlock Record unlocks it.

Installation

Before Installing

Besides installing the package below, it’s very important to make sure this setting is turned on:

Installation

Install Unmanaged 1.0.0.1

For Developers

View Source Code

Old Versions

Install Unmanaged 1.0

0 0 vote
Article Rating
Subscribe
Notify of
guest
10 Comments
Inline Feedbacks
View all comments
Charlotte Bergan
Charlotte Bergan
5 months ago

Hey Alex, I installed this and the Flow doesn’t look the same. Is there a newer version of the package? And will I be able to create an action button with it? (Currently Flow doesn’t show up as an option even though it’s Active)

Jerun Stanley
Jerun Stanley
3 months ago

Looks like you can’t call this flow directly from an action. You would need to create an intermediary lightning component or visualforce page.

See the answer at https://salesforce.stackexchange.com/questions/238254/calling-flow-from-lightning-quick-action

Jerun Stanley
Jerun Stanley
3 months ago
Reply to  Jerun Stanley

I ended up coding this myself. Code below for anyone interested: Apex class: public class UnlockRecordController { @AuraEnabled public static Boolean isUnlockAllowed(String recordId){ Id recId = Id.ValueOf(recordId); String objAPI = recId.getSobjectType().getDescribe().getName(); list objPerm = [SELECT Id FROM ObjectPermissions WHERE PermissionsModifyAllRecords = true AND SobjectType = :objAPI AND ParentId IN (SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId = :UserInfo.getUserId())]; return Approval.isLocked(recId) && !objPerm.isEmpty(); } @AuraEnabled public static boolean unlockRecord(String objId){ List unlockrec = new List(); unlockrec.add(objId); Approval.UnlockResult[] unlockedRersult = Approval.unlock(unlockrec); return true; } } Aura component file: Aura controller file: ({ doInit : function(component, event, helper) { var action = component.get(“c.isUnlockAllowed”); action.setParams({… Read more »

Anonymous
Anonymous
3 months ago

If I have an approval process and do not want the record locked at all, how do I give users without Modify All the ability to do this?

Anonymous
Anonymous
2 months ago

It doesn’t seem to allow you to load this in a sandbox or am I missing something?

Alex Edelstein
Admin
2 months ago
Reply to  Anonymous

change the url from login.salesforce.com to test.salesforce.com and it should install.

andy
andy
2 months ago

Can I add this to custom objects?

James Roberts
James Roberts
1 month ago

Hi Alex,

I installed this package, but I’m getting an insufficient access error when the user tries to unlock – what access level do they need?

UNLOCKRECORD (APEX): Unlock_Record
Inputs:
recordId = {!recordId} (a1H55000006l3UJEAY)
________________________________________
Error Occurred: An Apex error occurred: System.DmlException: Delete failed. First exception on row 0 with id 04Z550000003Oqv; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []