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
scottrmscottrm 

how to creat eand authorise approval request in apex when logged in as a user with lower privileges

I have some code based on this example there http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_process_example.htm which creates and approves an approval request. It works fine if I am logged in as sysamdin but if a user with lower privilges is logged in I get an error on the line

 

Approval.ProcessResult result2 =  Approval.process(req2);

 

The error message is

 

First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY,

 

Is there any way to make this code work for a user with lower privileges?

SteveBowerSteveBower

Fast thought: did you specify "with sharing" on your class definition?  Best, Steve.

scottrmscottrm

Yes with sharing was specified