1. Was I using the wrong Id type for setWorkItemId()? No, the Id is definitely that of a ProcessInstanceWorkItem, and when I test and look at the item in my org, it is an open, actionable work item that I can choose to Approve or Reject manually.
2. When I make the query for a ProcessInstanceWorkItem, am I retrieving the wrong one? No - when testing, there is only one ProcessInstanceWorkItem to query for on the record's ProcessInstance, and as above, it is actionable. There is no way that the query could get the wrong item.
3. Is there some other field that is the root cause of this issue? This doesn't seem possible, as the Id in setWorkitemId() is the only Id field that I am providing the Approval.process() method.
Was I using the wrong Id type for setWorkItemId()? No, the Id is definitely that of a ProcessInstanceWorkItem, and when I test and look at the item in my org, it is an open, actionable work item that I can choose to Approve or Reject manually.
When I make the query for a ProcessInstanceWorkItem, am I retrieving the wrong one? No - when testing, there is only one ProcessInstanceWorkItem to query for on the record's ProcessInstance, and as above, it is actionable. There is no way that the query could get the wrong item.
Is there some other field that is the root cause of this issue? This doesn't seem possible, as the Id in setWorkitemId() is the only Id field that I am providing the Approval.process() method.
I have tried tons of different methods to fix this, mostly from online recommendations. At this point I would be extremely surprised if you could dig up another StackOverflow or Salesforce Developer Forum post that is suggesting something that I have not already tried (and that did not work).
Please help me investigate this issue. It is the source of development delays (not to mention headaches).