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
purpurnellpurpurnell 

How to uncheck checkboxes when a new checkbox has been selected?

I am looking for feedback on my code.  If my Financial Account Role Object has a new primary contact checkbox checked, then the other checkboxes are unchecked.

My code worked 2 days ago but now I can't figure out why it isn't working.  Please give me some feedback as to what I am doing wrong.

 public static void afterUpdate(Map<Id,FinServ__FinancialAccountRole__c> newmap,Map<Id,FinServ__FinancialAccountRole__c> oldMap){
        if(UserInfo.getName()!= 'Integration User'){
            
            Set<Id>FinAcctIds = new Set<Id>(); //Collection of Financial Account Ids
            Set<Id>FinActRoleIds_PC = new Set<Id>(); //Collection of Financial Account Role Ids
            Set<Id>FinAcctIdstoSendtoBoomi = new Set<Id>(); //Collection of Financial Account Ids for API Callout
            
            List<FinServ__FinancialAccountRole__c> testfinAcct = new List<FinServ__FinancialAccountRole__c>();
            System.debug('Financial Account Role ' + testfinAcct);
            
            for(FinServ__FinancialAccountRole__c FinAcctRole : newmap.values()){
                if(FinAcctRole.Primary_contact__c == true && newmap.get(FinAcctRole.Id).Primary_contact__c != oldmap.get(FinAcctRole.Id).Primary_contact__c)
                {
                    FinAcctIds.add(finAcctRole.FinServ__FinancialAccount__c);
                    FinActRoleIds_PC.add(FinAcctRole.Id);
                    FinAcctIdstoSendtoBoomi.add(FinAcctRole.Id);
                } 
            }
                
            Map<Id, FinServ__FinancialAccountRole__c> OldPrimaryMap = new Map<Id, FinServ__FinancialAccountRole__c>();
            List<FinServ__FinancialAccountRole__c> OldFinAcctRoles = new List<FinServ__FinancialAccountRole__c>();
            List<FinServ__FinancialAccountRole__c> Old_FinAcctRoleList = [SELECT Primary_Contact__c,Id, FinServ__FinancialAccount__c FROM FinServ__FinancialAccountRole__c where Primary_Contact__c = true and Id NOT IN: FinActRoleIds_PC and FinServ__FinancialAccount__c IN: FinAcctIds];
                for(FinServ__FinancialAccountRole__c FinAcctRole : Old_FinAcctRoleList)
                {
                    FinAcctRole.Primary_Contact__c = false;
                    OldFinAcctRoles.add(FinAcctRole);
                    FinAcctIdstoSendtoBoomi.add(FinAcctRole.Id);
                }
            
            if(OldFinAcctRoles.size()>0){
                update OldFinAcctRoles; 
            }            
        }
  }  
jen ferjen fer
Ever wanted to download a file using Google Chrome browser but receive a prompt telling you Chrome has detected a malicious file and blocked it? Here you can check this https://tg170.com/how-to-stop-chrome-from-blocking-downloads/ to know how to stop chrome from blocking downloads.
ANUTEJANUTEJ (Salesforce Developers) 
Hi Purpurnell,

Are you getting any errors as such and also can you check if the flow of code snippet is proper?

Thanks.