1
Approval.ProcessWorkitemRequest singleApprovalProcess = new 
Approval.ProcessWorkitemRequest();
singleApprovalProcess.setComments('Reason here.');
singleApprovalProcess.setAction('Approve');
singleApprovalProcess.setWorkitemId(recordId);
Approval.ProcessResult result = Approval.process(singleApprovalProcess);

I am trying to approve the record from apex and getting the following error:

INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [].

this error does not occur when I approve the record through the UI.

I am running the code as a Sys Admin

3
  • 2
    Even a sys admin needs to be granted access to objects and fields - something they can do for themselves, of course. Also, if they do not have the view or modify all data permissions then record sharing can still apply to them. Double check your setup and perhaps also read this.
    – Phil W
    Commented Mar 29 at 11:59
  • @PhilW but this error does not occur when I approve the record through the UI. Commented Mar 31 at 23:04
  • If it uses a different processing flow different rules may apply. Just make sure to check you setup in detail.
    – Phil W
    Commented Apr 1 at 7:04

0

You must log in to answer this question.

Browse other questions tagged .