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
Collin EdlCollin Edl 

Code removing contact account association

We have a bit of code for our Live Agent piece that was done by a consultant a few years back. Recently we've been having issues where our contacts are being made "Private" and having the associated account removed. Is there anything in this code that could be doing this?
 
trigger ConsoleUpdate on Contact (before Insert,Before Update) {
    Map<Id,Id> RelatedAccountContact = New Map<Id,Id>();
    Map<Id,String> RelatedAccount = New Map<Id,String>();
    Map<Id,Id> RelatedAccountContactwithNulls = New Map<Id,Id>();
    List<contact> contactList = New List<Contact>();
    for(contact c :trigger.new){
         if(c.Account_Related_To__c!=null){
             String AccountId = c.Asurint_Acct_Id__c;
             RelatedAccount.put(c.id,AccountId);
             contactList.add(c);
         }
    }
    if(contactList.Size()>0){
        id DefaultAcctId = ([Select Id from Account where name = 'Default Account(Live Agent Only)'])[0].Id; 
        Map<String,id> AcctDetailsMap = New Map<String,id>();
        List<Account> AvailableAccounts = [Select Id,CSI_Account_ID__c from Account where CSI_Account_ID__c In: RelatedAccount.Values()];
        for(Account A : AvailableAccounts){
            AcctDetailsMap.put(A.CSI_Account_ID__c,A.id); 
        }
        for(contact c:contactList){
            if(AcctDetailsMap.get(RelatedAccount.get(c.id))!= Null ){
                RelatedAccountContactwithNulls.put(c.id,AcctDetailsMap.get(RelatedAccount.get(c.id)));
            }
            else{
                RelatedAccountContactwithNulls.put(c.id,DefaultAcctId );
            }
        }
        for(contact c:trigger.new){
            c.accountId = RelatedAccountContactwithNulls.get(c.Id);
        }
    }
}