I don't see a way to unlock a record that is locked by approval process.IsLocked flag is not accessible through api.Is there any way to do this.
3 Answers
As of Winter '16, this is now possible through APEX. (Release Notes)
It can be enabled by going to Setup > Create > Workflow & Approvals > Process Automation Settings :
EDITOR NOTE
As mentioned in other answers, this feature is now possible out of the box as of Winter '16.
Original Answer
not out of the box.
What we did in a client project was:
- Create RecordLockStatus__c picklist field with valuess [UNLOCKED, IN_APPROVAL, LOCKED]
- Create UnlockToken__c text field
- Create an approval process with entry criteria RecordLockStatus__c='LOCKED' and UnlockToken__c = ?SEMI_SECRET_TOKEN? to prevent accidental unlock and sets RecordLockStatus__c='UNLOCKED' and UnlockToken__c=NULL. Make sure to set the approval's order to 1.
- For all your other approvals make sure that you set RecordLockStatus__c= 'IN_APPROVAL' when entering the approval and RecordLockStatus__c='LOCKED' when locking the record on finish
- To unlock your record query it (make sure RecordLockStatus__c='LOCKED') and submit for approval using Apex http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_process.htm
hope that helps
-
Will the record gets unlock without taking ownership of record after following your above steps?– sfdcCommented Sep 9, 2013 at 16:22
-
that depends on how you setup the approval. following the steps above it wont, but of course you and re-assign the record in the unlock workflow if needed Commented Sep 9, 2013 at 17:24
-
I know this is kindof an old bump but SF has an example of approving/rejecting a record in Apex. salesforce.com/us/developer/docs/apexcode/Content/… Commented Dec 18, 2013 at 17:24
-
-
You can now: releasenotes.docs.salesforce.com/en-us/winter16/release-notes/…– willardCommented Jan 6, 2016 at 22:02
Apex doesn't expose any class/method to unlock a record. There are only two ways a record can be unlocked that is locked by the approval process.
- The 'Final Approval Action' of the process does have the feature to unlock a record.
- A button labelled 'Unlock record' will be visible (only)to system administrators and only they can unlock a record locked by an approval process.