I have this class wherein if the Accountid is not equal to contactID it should update the enddate to today. the problem is that it doesn't update the enddate to today date
public with sharing class AccountContactChangeClass {
public static void AccountContactChange (map<Id, Contact> acctChangeContactsMap){
List<Accountcontactrelation> acccn;
System.debug('Test1 = ' + acccn);
if(acctChangeContactsMap!= null){
List<Accountcontactrelation> acrn = New List<Accountcontactrelation>([SELECT AccountId,ContactId,CreatedById,CreatedDate,CurrencyIsoCode,EndDate,Id,IsActive,IsDeleted,IsDirect,LastModifiedById,LastModifiedDate,Roles,StartDate,SystemModstamp FROM AccountContactRelation where contactid in : acctChangeContactsMap.keyset()]);
System.debug('Test2 = ' + acrn);
for (Accountcontactrelation arnt : acrn){
if(arnt.accountid != acctChangeContactsMap.get(arnt.contactid).account.id)
{
arnt.enddate = system.today();
System.debug('Test5 = ' + arnt);
acccn.add(arnt);
System.debug('Test6 = ' + arnt);
}
}
update acccn;
System.debug('Test8 = ' + acccn);
}
}}