You need to sign in to do that
Don't have an account?
Day dreamer
I used Approval.unlock() methods, but it didnt unlock my record.
Inside my trigger method i wrote below code:
public void OnBeforeUpdate(List<Account> newAccList ,List<Account> oldAccList ){
Approval.UnlockResult[] lrList = Approval.unlock(oldAccList, false);
system.debug('-----lrList-----'+lrList);
}
In debug log below ,I have no errors and isSucess flag set to true, but my record is still locked :
----lrList-----(Approval.UnlockResult[getErrors=();getId=00163000004DNG6;isSuccess=true;])
Has anyone used this new feature of winter 16 sucessfully?or can anyone advice why it is not working for me?
public void OnBeforeUpdate(List<Account> newAccList ,List<Account> oldAccList ){
Approval.UnlockResult[] lrList = Approval.unlock(oldAccList, false);
system.debug('-----lrList-----'+lrList);
}
In debug log below ,I have no errors and isSucess flag set to true, but my record is still locked :
----lrList-----(Approval.UnlockResult[getErrors=();getId=00163000004DNG6;isSuccess=true;])
Has anyone used this new feature of winter 16 sucessfully?or can anyone advice why it is not working for me?
See the below documentation.
https://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_apex_approval_locks_unlocks.htm
Instead of doing System.Debug with the result, do the below thing -
The record isn't unlocked until the record is approved. Just because it went from an insert to an update does not mean it is now approved. In fact, Approval Processes aren't processed until the end of the transaction, so it's considered locked until the end of the transaction, when it is updated via the workflow rule processing step. Furthermore, records that enter the approval process will stay locked until they are actually approved or removed from the process.
Check the Order of Exceution also -
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
Please select this as "best answer" if it helps. Thanks.