1

I have Accounts and Contacts as M:M in the system and a simple apex code that creates junction objects.

@RemoteAction
    global static Boolean addContacts(String[] arr, String acc_id){
        if(arr == null || acc_id == null){
            return false;
        }
        System.debug(arr);
        List<AccountContactAssociation__c> toInsert = new List<AccountContactAssociation__c>();
        for(String contId : arr){
            AccountContactAssociation__c aca = new AccountContactAssociation__c();
            aca.Account__c = acc_id;
            aca.Contact__c = contId; 
            toInsert.add(aca);
        }
        if(!toInsert.isEmpty()){
            insert toInsert;
            return true;
        } 
        return false;
    }

Also I have only 2 profiles - admin and "Custom". "Custom" profile has permissions to Contact, Account and junction objects as Read, Create, Edit and View All. Several days ago we received this error after "Custom" user tried to add contacts to account:

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id

Trick is that it was working for almost 10 months before and only now there are problems. Sharing rules for Accounts and Contacts are Public Read/Write.

4
  • Could you post the apex that you're referencing? It would be helpful to understand what might be causing the error.
    – HomerJ
    Jun 19 '15 at 12:24
  • @RemoteAction global static Boolean addContact(String[] arr, String acc_id){ if(arr == null || acc_id == null){ return false; } System.debug(arr); List<AccountContactAssociation__c> toInsert = new List<AccountContactAssociation__c>(); for(String contId : arr){ AccountContactAssociation__c aca =\ new AccountContactAssociation__c(); aca.Account__c = acc_id; aca.Contact__c = contId; toInsert.add(aca); } if(!toInsert.isEmpty()){ insert toInsert; return true; } return false; } Jun 19 '15 at 12:26
  • Please don't ask people to help you by trying to decipher code pasted into comments. Edit your post using the link at the bottom left of your question. When you post code, after pasting it into your post, please select it and click on the {} pre-formatted text icon so that it's legible to anyone who reads it.
    – crmprogdev
    Jun 19 '15 at 13:33
  • @crmprogdev Sorry, fixed. Jun 19 '15 at 13:38
1

Summer 15 was just released in all orgs. The timing suggests this may be related to Summer 15 having been released in your org. As you've only included the @remoteAction method of your Controller Class, it's impossible to assess whether or not there's something else in your Class or VF code that could be causing the issue.

If anything is trying to access the User Profile in your class, that would be where I'd be inclined to look, esp if your class is "withSharing", and sharing on Users is private. With SU 15, handling of sharing on Users has changed to where sharing permissions are now respected when sharing is set to private. See Summer 15 Release Notes for details on everything that's changed.

3
  • There is nothing related to User Profiles in my class, I use only Contact, Account and junction object. I can provide code of whole controller, but I am not sure that this would help. I tried to set my class as "without sharing" but it didn't helped and I still don't know how to fix it. Jun 25 '15 at 10:11
  • Just to confirm, your custom user profile has Read, Create, Edit and View All permissions on Contact, Account and junction Object named AccountContactAssociation__c, correct? Have you checked your Org's Audit Trail History for any recent changes? Also, I suggest you check All 3 objects above for any other related objects there may be look-ups to that the profile doesn't have access to. If that doesn't solve it, please post all of your code.
    – crmprogdev
    Jun 25 '15 at 14:15
  • Sorry, set my class as "without sharing" by my IDE didn't save it on server so that is why I was thinking that it didn't helped. Now it works. Jun 26 '15 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.