+ Start a Discussion
roni shoreroni shore 

Unable to add records to list <AccountContactRelation>

 Compile Error: Invalid type: AccountContactRelation
when adding record in list in last line, it throws error, pls suggest

List<AccountContactRelation> lstACR = new List<AccountContactRelation>();// error here
for(AccountContactRelation ACR : [Select Id, AccountId, ContactId, Roles from AccountContactRelation where ContactId =: sConId and 
                                                      AccountId in : accIds and Roles in : mapConRole.values()]) {
                                                          if(ACR.AccountId == opp.Ship__c)  
                                                              bShip = true;
                                                          if(ACR.AccountId == opp.Bill__c) 
                                                              bBill = true;
                                                        
                        }
 if(!bFoundShip)
                            lstACR.add(new AccountContactRelation(AccountId = opp.Ship__c, ContactId = sConId, Roles = sConRole));
Best Answer chosen by roni shore
roni shoreroni shore
it was versioning issue, ACR object do not support version 32 and less

All Answers

sowmya Inturi 9sowmya Inturi 9
Hi,
Make sure that you enabled Allow users to relate a contact to multiple company checkbox in Account Settings.

User-added image


Thanks,
Sowmya.
roni shoreroni shore
Hi, Its already enabled
roni shoreroni shore
it was versioning issue, ACR object do not support version 32 and less
This was selected as the best answer