• purpurnell
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
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; 
            }            
        }
  }  
How do I send an old Set of values and a new Set of values via a deserialized JSON body?

I have an array of  accountRoles and I need  to send them to an external database.