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
Vinod TomarVinod Tomar 

Exception in deleting record from PartnerNetworkRecordConnection object

We have code to share/unshare account with other Org using Salesforce to Salesforce connection. Code ws running fine but now when I unshare the account it throughs below error-

 

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger shareAccountWithSalesforceToSalesforce caused an unexpected exception, contact your administrator: shareAccountWithSalesforceToSalesforce: execution of AfterUpdate caused by: System.DmlException: Delete failed. First exception on row 0 with id 04V300000003cBlEAI; first error: INVALID_OPERATION, operation is not allowed: []: Class.SalesforceToSalesforce.unshareRecords: line 32, column 3".

 

when I debugg the issue then found that deletion is not allowed in PartnerNetworkRecordConnection object and below exception occured-

 

System.DmlException: Delete failed. First exception on row 0 with id 04V300000003cBlEAI; first error: INVALID_OPERATION, operation is not allowed: []

 

Can somebody help me how can I unshare the account?

Best Answer chosen by Admin (Salesforce Developers) 
Vinod TomarVinod Tomar

The error was due to recurssive call of trigger. I used the static variable to avoid the error.

All Answers

craigmhcraigmh

It sounds like you have a trigger causing issues. It's trying to delete a record after update, which you can't do.

Vinod TomarVinod Tomar

The error was due to recurssive call of trigger. I used the static variable to avoid the error.

This was selected as the best answer