I want to reassign a queue assigned to an approval request using apex. How can i achieve this,
I have tried updating processInstanceWorkItem object but it was throwing insufficient access error
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
To change the responsible for an approval request you have to update the
ActorId field on the
ProcessInstanceWorkItem object with the Id of the user you want to be the actual approver.
I just did this myself in a test org:
ProcessInstanceWorkItem pi = [SELECT Id, ActorId FROM ProcessInstanceWorkItem LIMIT 1]; pi.ActorId = '0051I0000027LCVQA2'; update pi;
And it worked just fine. I even got a message stating that the request was reassigned:
Of course, I executed that snippet with an administrator user, so if you are trying to do this in, say, a trigger called by a non-admin user, you might want to take a look in the sharing keyword. What you got might be an error due to the privileges for that non-admin user.