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
Mick MuMick Mu 

Salesforce to Salesforce

Hi all,

 

Im using the following code to send over an account and its related opportunity:

 

List<PartnerNetworkRecordConnection> accountConnections =  new List<PartnerNetworkRecordConnection>();
                
            for (Account newAccount : localAccount)
            {                 
                PartnerNetworkRecordConnection newConnection =
                new PartnerNetworkRecordConnection
                (
                    ConnectionId = networkId,
                    LocalRecordId = newAccount.Id,
                    RelatedRecords = 'Opportunity',
                    SendClosedTasks = true,
                    SendOpenTasks = true,
                    SendEmails = true,
                    //ParentRecordId = newContact.AccountId
                    
                    ParentRecordId = null
                 );
                         
                accountConnections.add(newConnection);
             } 

database.insert(accountConnections);

 

this works fine if the owner of the account is the owner of the opportunity, but if the owners are different i get an error:

 

salesforce INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

 

has anyone any idea why? im stumped.

 

Thanks

 

AdrianCCAdrianCC

Hello,

 

Try to give the profile of the second user the "Modify All" permission. That should take care of your error.

 

Thanks,

Adrian