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
David.HEDavid.HE 

How to know if a user has permissions over an approval process

I have a button for recalling an opportunity for an approval process, but when a user that is not who has submited the opportunity or an administrator recall it, then he gets an error : INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY
That error is fired on just the line what processes the recalling
{
            Approval.ProcessWorkItemRequest pwr = new Approval.ProcessWorkItemRequest();
            pwr.setWorkitemId(w.id);
            pwr.setAction('Removed');
            System.debug('We get an error with this '+ pwr);
            Approval.ProcessResult pr = Approval.process(pwr);
}

What I want to do is to check if the user has edit access over the approval process. But how can I achieve it?

I know how to check if a user has edit access over a record , querying the table UserRecordAccess , but it doesn't work in this case.
NaveenReddyNaveenReddy
Hi,

   Once the record is submitted for approval the record gets locked for editing for submitter.

Next approver1 can edit ,reject or approve the  record.If he rejects the record it will be reassigned to submiiter, now he gets access to edit the record.

Only Submiiter and approvers  defined in the approval process can have the edit access over the record when the record gets assigned to them in particular step.

For more information please refer below links.

http://salesforce.stackexchange.com/questions/16669/resubmit-approval-process-if-record-edited

https://help.salesforce.com/apex/HTViewHelpDoc?id=what_are_approvals.htm&language=en_US

Regards,
Naveen
SSE , Salesforce CI expert group
http://www.autorabit.com"