function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PoornaPrabhu SeenivasanPoornaPrabhu Seenivasan 

Approval.lock() and Approval.unlock() methods return System.UnexpectedException: null

Hello All,

I'm getting a System.UnexpectedException: null error while trying to unlock or lock the records from a Queueable Apex job.
I would need someone's advise to resolve this error as soon as possible.

My scenario is as below:

I want to update a set of opportunities out of which a few of them are locked by the approval process.
So I want to unlock these opportunities, update a particular field in the opportunity and lock the record again via apex.
I have used the standard approval process.

Please advise.
 
Pranav KulkarniPranav Kulkarni
Hello PoornaPrabhu, 
I am also facing same issue. Could you please let us know if you got solution?
Thank you-
Shrivaths
Bruno B. AffonsoBruno B. Affonso
//The new Approval.UnlockResult class contains methods that show
//the results of record unlocks by System.Approval.unlock() methods.
//A Boolean value that is set to true if the unlock operation is successful
//for this object, or false otherwise.
Boolean result = System.Approval.unlock(oppId).isSuccess();
Leandro Santillan 6Leandro Santillan 6
Same here..Approval.lock() returns an error message. It worked find until October 23rd, not sure what the problem is.
System.UnexpectedException: null
mDizz_7mDizz_7
I had the same problem. I move my API version on my class from 31 to 35 and that fixed the issue.
Maureen Cassidy 14Maureen Cassidy 14
I had the same problem. Changed API version on my class from 25 to 35 and that fixed the issue.
Harry LiuHarry Liu
I had the same problem. Changed API version on my class from 30 to 35 and that fixed the issue.