You need to sign in to do that
Don't have an account?
sfadm sfadm
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on object id
Hello,
I'm having an issue changing the Account owner on my production environment due to the following error:
The error happens only for one Account record when I try to change the Owner of that Account record.
I do not have issues and do not receive the above error when I change the Owner for other account records.
Here is the code of the afterUpdate() method:
Could you please advise what is the causing the error and help me find a solution.
Thank you
I'm having an issue changing the Account owner on my production environment due to the following error:
19:54:05.0 (166999959)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:Account:0011400001cjq0g 19:54:05.0 (167016943)|VALIDATION_RULE|03d30000000fi7e|Sponsored_Merchant 19:54:05.0 (167220072)|VALIDATION_FORMULA|AND( ISPICKVAL( Merchant_Type__c , "SPONSORED" ), ISBLANK( IPSP__c ) )|IPSP__c=null , Merchant_Type__c=DIRECT 19:54:05.0 (167227568)|VALIDATION_PASS 19:54:05.0 (167277354)|CODE_UNIT_FINISHED|Validation:Account:0011400001cjq0g 19:54:05.0 (451026437)|CODE_UNIT_STARTED|[EXTERNAL]|01q140000000GUT|AccountTrigger on Account trigger event AfterUpdate for [0011400001cjq0g] 19:54:05.0 (452368872)|SYSTEM_MODE_ENTER|false 19:54:05.0 (453035097)|SOQL_EXECUTE_BEGIN|[245]|Aggregations:0|SELECT Id, OwnerId, IsRecurrence, RecurrenceActivityId FROM Task WHERE (IsClosed = FALSE AND (IsRecurrence = TRUE OR RecurrenceActivityId = '') AND AccountId = :tmpVar1) 19:54:05.0 (495584380)|SOQL_EXECUTE_END|[245]|Rows:1 19:54:05.0 (496143245)|DML_BEGIN|[251]|Op:Update|Type:Task|Rows:1 19:54:05.0 (570382518)|DML_END|[251] 19:54:05.0 (571909416)|SOQL_EXECUTE_BEGIN|[258]|Aggregations:0|SELECT OwnerId, Name, AccountId FROM Opportunity o WHERE o.AccountId = :tmpVar1 19:54:05.0 (575827437)|SOQL_EXECUTE_END|[258]|Rows:1 19:54:05.0 (576343858)|DML_BEGIN|[264]|Op:Update|Type:Opportunity|Rows:1 19:54:05.0 (591807513)|DML_END|[264] 19:54:05.0 (591887610)|EXCEPTION_THROWN|[264]|System.DmlException: Update failed. First exception on row 0 with id 0061400001BE4EZAA1; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: [] 19:54:05.0 (592744047)|SYSTEM_MODE_EXIT|false 19:54:05.0 (592895440)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id 0061400001BE4EZAA1; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: [] Class.AccountHandler.afterUpdate: line 264, column 1 Class.TriggerFactory.execute: line 153, column 1 Class.TriggerFactory.createHandler: line 29, column 1 Trigger.AccountTrigger: line 3, column 1 19:54:05.0 (592922730)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id 0061400001BE4EZAA1; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: [] Class.AccountHandler.afterUpdate: line 264, column 1 Class.TriggerFactory.execute: line 153, column 1 Class.TriggerFactory.createHandler: line 29, column 1 Trigger.AccountTrigger: line 3, column 1 19:54:05.592 (592930478)|CUMULATIVE_LIMIT_USAGE
The error happens only for one Account record when I try to change the Owner of that Account record.
I do not have issues and do not receive the above error when I change the Owner for other account records.
Here is the code of the afterUpdate() method:
public void afterUpdate(SObject oldSo, SObject so) { if(Trigger.isUpdate) { // Cast the SObject to an Account Account newAccount = (Account)so; Account oldAccount = (Account)oldSo; List<Task> tasksList = new List<Task>([SELECT Id, OwnerId, IsRecurrence, RecurrenceActivityId FROM Task WHERE IsClosed=false AND (IsRecurrence = true OR RecurrenceActivityId = '') AND AccountId = :oldAccount.Id]); for (Task tl: tasksList) { for(Task to: tasksFromDatabase) { if(tl.Id == to.Id) { tl.OwnerId = to.OwnerId; update tl; } } } if(newAccount.OwnerId != oldAccount.OwnerId) { List<Opportunity> opportunityExists = [select OwnerId, Name, AccountId from Opportunity o where o.AccountId = :newAccount.Id]; for (Opportunity opp : opportunityExists) { opp.OwnerId = oldAccount.OwnerId; } sObject[] sObjects = opportunityExists; update(sObjects); } } }
Could you please advise what is the causing the error and help me find a solution.
Thank you
19:54:05.0 (591887610)|EXCEPTION_THROWN|[264]|System.DmlException: Update failed. First exception on row 0 with id 0061400001BE4EZAA1; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []
The ID you see is of an opportunity : 0061400001BE4EZAA1 - Looks like you do not have sufficient rights on changing the owner of this opportunity as you seem to be doing in the trigger in the code below:
if(newAccount.OwnerId != oldAccount.OwnerId) { List<Opportunity> opportunityExists = [select OwnerId, Name, AccountId from Opportunity o where o.AccountId = :newAccount.Id]; for (Opportunity opp : opportunityExists) { opp.OwnerId = oldAccount.OwnerId; } sObject[] sObjects = opportunityExists; update(sObjects); }
Please check the acocunt which is throwing this exception and check for the opportunity to see if you have edit rights on this opportunity.