• A
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 4
    Replies
Hi ,
 Below is the error I'm getting while sharing from one community user to another user

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: insufficient access rights on cross-reference id.

I was able to see the error in debug log.

Can any one plese help me out here.

Please find below code:

trigger ArticleShare on Article__c (after insert,After update) {
public list<Article__Share> artShareList = new list<Article__Share>();
public list<FeedItem> listOfFeedFiles = new List<FeedItem>();
public attachment objAttachment;
public string usId;
   if(trigger.isAfter){
       if(trigger.isInsert){
           for (article__c a : trigger.new){
               if(a.domain__c!=null || a.domain__c!=''){
               system.debug('__________a.domain__c_______'+a.domain__c);
               for(user u :[select id,name from user where email=:a.domain__c  limit 1]){
                   usId = u.id;
                   system.debug('__________u.id______'+u.id);    
                   //UserOrGroupId  a.Owner.UserRoleId rowCause ='Apex Share' Owner.UserRoleId;
                   system.debug('______a.Owner.UserRoleId_________'+a.Owner.UserRoleId);
                   system.debug('______a.OwnerId________'+a.OwnerId);
                   system.debug('__________u.id______'+u.id);    
                   //system.debug('______u.Owner.UserRoleId______'+u.Owner.UserRoleId);
                   //system.debug('__________u.id______'+u.OwnerId);    
                   Article__Share newartShare = new Article__Share (ParentId  = a.id,UserOrGroupId =u.id,AccessLevel='Read');
                   artShareList.add(newartShare);
                   system.debug('__________artShareList______'+artShareList);    
               }
               
                      
               }
           }
           //insert artShareList ;
           
           
            try {
            Database.SaveResult[] shareInsertResult = Database.insert(artShareList,false);
             for (Database.SaveResult sr : shareInsertResult) {
            if (sr.isSuccess()) {
                
                System.debug('_____Successfully inserted account. Account ID:___ ' + sr.getId());
            }
            else {
                
                for(Database.Error err : sr.getErrors()) {
                    System.debug('_______The following error has occurred___________.'+err.getMessage());                    
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    
                }
            }
        }

        } 
        catch (Exception e) {
            System.debug(e.getTypeName() + ' - ' + e.getCause() + ': ' + e.getMessage());
        }
           
           
           
       }
   }
   if(trigger.isAfter){
       if(trigger.isUpdate){
           for (Article__c a : trigger.new){
               if(a.domain__c!=null || a.domain__c!=''){
                   
                       for(user u :[select id,name from user where email=:a.domain__c  limit 1]){
                       Article__Share newartShare = new Article__Share (ParentId = a.id,UserOrGroupId =u.id,AccessLevel='Read');
                       artShareList.add(newartShare);
                      
                       
                   }
                   
               }
        
               }
               
               
              //insert artShareList;
              
               try {
            Database.SaveResult[] shareInsertResult = Database.insert(artShareList,false);
             for (Database.SaveResult sr : shareInsertResult) {
            if (sr.isSuccess()) {
                // Operation was successful, so get the ID of the record that was processed
                System.debug('_____Successfully inserted account. Account ID:___ ' + sr.getId());
            }
            else {
                // Operation failed, so get all errors                
                for(Database.Error err : sr.getErrors()) {
                    System.debug('_______The following error has occurred___________.'+err.getMessage());                    
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    //System.debug(err.getTypeName() + ' - ' + err.getCause() + ': ' + err.getMessage());
                    
                }
            }
        }
        } 
        catch (Exception e) {
            System.debug(e.getTypeName() + ' - ' + e.getCause() + ': ' + e.getMessage());
        }
           }
           
           
          
       }
   

}
Hi All,

Can any one please share the code for Apex sharing to the attachment of case object?

Thanks,
  A
Hi Floks,

Can any one please share the code(vf,controller) for Multi-select Custom lookup?

Thanks for taking time to help! 

Hi ,

 

I want to remove setup from user menu for one profile.

Please guide me to solve this.

 

Regards,

Aravind

9701508070