Skip to content

Illegal Transition Type Error when Approving Records via Apex

First exception on row 0; first error: INVALID_OPERATION, Illegal transition type: [] Error when Approving Records via Apex.

Illegal Transition Type Error in Approval Process
Illegal Transition Type Error Message

When you will you encounter Illegal Transition Type error?

You encounter “First exception on row 0; first error: INVALID_OPERATION, Illegal transition type: []” error when using ProcessWorkitemRequest class for processing an approval request after it is submitted..

// Sample code for submitting record for Approval using ProcessWorkitemRequest

Approval.ProcessWorkitemRequest aWorkItem = new Approval.ProcessWorkitemRequest();
aWorkItem.setComments('Comments');
aWorkItem.setAction('Approve');
aWorkItem.setWorkitemId('04i2i000000jA3O');
//Submit request for approval
Approval.ProcessResult approvalResult =  Approval.process(aWorkItem);

Error Message:

Error Occurred: An Apex error occurred: System.DmlException: Process failed. First exception on row 0; first error: INVALID_OPERATION, Illegal transition type: [] 

How can you resolve the Illegal Transition Type Error when Approving Records via Apex?

Salesforce only supports following actions:

  • Approve
  • Removed ( Only system administrators can specify Removed)
  • Reject

If you pass any other action (For Example: ‘Approved’ instead of ‘Approve’ ) as setAction parameter then you will get Illegal transition Type Error.

Additional Resources

Did you find this article useful? Please us know in comments!


Tags:

Share this article...

Please Leave a Comment

error: Content is protected !!

Discover more from DYDC

Subscribe now to keep reading and get access to the full archive.

Continue reading