You need to sign in to do that
Don't have an account?

Approving the Submited Approval through Apex code
I am Facing the problem when i am Approving the Submited Approval through Apex code
and i am countered with this error pl help me out .
System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id
public void Reject (){
update perform;
Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest();
req2.setComments('Rating are not up to the mark');
req2.setAction('Reject'); //This is the action that is approve in your case, you can set it to Reject also
req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});
// Use the ID from the newly created item to specify the item to be worked
req2.setWorkitemId(perform.id);
// Submit the request for approval
Approval.ProcessResult result2 = Approval.process(req2);
System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess());
System.assertEquals(
'Approved', result2.getInstanceStatus(),
'Instance Status'+result2.getInstanceStatus());
}


