function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ryan Werner 22Ryan Werner 22 

Approval process through Apex - setting a submitter Id security context

In our implementation we originally had security on an object set to Public Read/Write. Along with this we have Apex functionality to submit a record for approval where the person submitting is not the record owner, but the Apex they are invoking is setting the setSubmitterId to the record owner's Id.

Now we want to tighten security on this object to Private and it is breaking our Apex code. I am having trouble debugging and truly identifying the issue, but my assumption is even though the Apex code being invoked is setting the submitter Id as the record owner, since the Apex itself is being run by a different user, the approval process is failing to run since the person running the Apex itself isn't the record owner and sharing is private.

Is it correct to assume an approval process runs in the context of who invokes it, and not who is set as the submitter Id?
PriyaPriya (Salesforce Developers) 

Hi Ryan

The Approval process run in system mode, try using without sharing key word in your apex.

If it resolve the issue, please mark it as best answer.

regards,

Priya Ranjan