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

Subscribe
Notify of
guest
14 Comments
Inline Feedbacks
View all comments
Charlotte Bergan

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

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

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 »

Joachim Rahlf

Hi Alex, one problem here – normal User with no Modify All cannot unlock and throws error as below: System.DmlException: Delete failed. Even if the Flow is run in system context with Access all data (Summer ’20) – any ideas ?

Anonymous

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

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

Alex Edelstein

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

andy

Can I add this to custom objects?

Joachim Rahlf

Same problem here – normal User with no Modify All cannot unlock and throws error as below: System.DmlException: Delete failed. Even if the FLow is run in system context with Access all data (Summer ’20)

James Roberts

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: []

Joachim Rahlf

Same problem here – normal User with no Modify All cannot unlock and throws error as below: System.DmlException: Delete failed. Even if the FLow is run in system context with Access all data (Summer ’20)

Justin Carter

I am seeing some strange behavior when interacting with an approval process: if the record is in an approval process and locked, users with editability permissions as set by the approval process can modify the record.

However, if the record is then unlocked and then locked using the actions provided here, those users can no longer edit the record.

Salesforce documentation indicates that programmatic locks should observe the same editability settings as those initiative by an active approval process. Any ideas as to why I am seeing this behavior?