You need to sign in to do that
Don't have an account?
purpurnell
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;
}
}
}
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;
}
}
}
Are you getting any errors as such and also can you check if the flow of code snippet is proper?
Thanks.