You need to sign in to do that
Don't have an account?
gtindu
Update ProcessInstanceWorkItem in an @future method
I have an @future method that runs to reassign open approval requests based on Out of office rules. If I don't have the method decorated @future - I have no issues everything works fine. But if I decorate the method @future - i get a NullReference exception
System.DmlException: Update failed. First exception on row 0 with id 04iXXXXXXXXXXXXXXX; first error: UNKNOWN_EXCEPTION, java.lang.NullPointerException: Argument Error: Parameter value is null: []
The only thing that changed is the @future decorator. I would like to use this in Code Scheduler - but I also get the same error. Anyone worked around this?
Can you please post the @future code that updates the ProcessInstanceWorkItem?
Well, can you specify what is the signature of this method which you are decorating as @future?
Note - if this method was operating on some instance variables of the class it is part of, then instance variables will not be available to the method when you decorate it with @future annotation.
Reason is @future executes asynchronously at later point and hence @future method would not be having references to class level instance variables.
This could be the reason of NullPointerException from @future decorated method.
Solution - if you needed to work on sObject record within @future method, make sure when you call this method, you pass the ID of the sObject record as an argument of the method. Now within @future you can fire SOQL on sObject id to retrieve the relevant details and process the record further.
Hope this helps. Please mark it a solution if your issue has been addressed.
Thanks
If I try running the above - i will get a failure with null reference on the DML statement for update. The ActorID is not null... and if I remove the @future - it works just fine.
I get the same symptoms as @future when I run as part of a schedulable apex job.