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.
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 :
As mentioned in other answers, this feature is now possible out of the box as of Winter '16.
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
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.