You need to sign in to do that
Don't have an account?
sfadm sfdev
Why is the INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []
Hello,
Could you please help me understand why I receive the following error:
The code in the apex class that I'm using is:
It is quite urgent to find a solution.
Thank you
Could you please help me understand why I receive the following error:
Delete failed. First exception on row 0 with id 04Z7E000000596S; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: [] Error is in expression '{!processRecord}' in component <apex:page> in page unlockopportunityrecord: External entry pointevery time I try to unlock an Opportunity record.
The code in the apex class that I'm using is:
public with sharing class UnlockRecordDuringApprovalController { Opportunity objOpportunity; String objOpp; public UnlockRecordDuringApprovalController(ApexPages.StandardController controller) { objOpportunity = (Opportunity)controller.getRecord(); } public void processRecord() { Approval.UnlockResult unlockedRersult = Approval.unlock(objOpportunity); // Iterate through each returned result if (unlockedRersult.isSuccess()) { // Operation was successful, so get the ID of the record that was processed System.debug('Successfully unlocked opportunity with ID: ' + unlockedRersult.getId()); } else { // Operation failed, so get all errors for(Database.Error err : unlockedRersult.getErrors()) { System.debug('The following error has occurred.'); System.debug(err.getStatusCode() + ': ' + err.getMessage()); System.debug('opportunity fields that affected this error: ' + err.getFields()); } } } }and the Visual Force page code is:
<apex:page standardController="opportunity" extensions="UnlockRecordDuringApprovalController" action="{!processRecord}" > </apex:page>Could you please explain what is causing this error to appear and prevent the unlock of the Opportunity record?
It is quite urgent to find a solution.
Thank you
Try removing the with sharing clause from your apex class. It looks like the user who is trying to unlock record doesnt have the permission to do so.
All Answers
Try removing the with sharing clause from your apex class. It looks like the user who is trying to unlock record doesnt have the permission to do so.
It really worked.
Thank you so much.
This time however I'm having this error message:
I have created my own custom button and when the button is pressed the above code is executed but I receive the following error message: Could you please advise what is the cause of such error message and how it can be avoided?I'm using the following code to unlock the Opportunity record:
Thank you
This was a great help and certainly solved my issue for now, but I imagine Salesforce will eventually crack down on using the With Sharing keyword for things like this. Is there a permission that would allow a user to unlock a record with Approval.unlock(id) other than Modify All Data?
Thanks!
Duncan