You need to sign in to do that
Don't have an account?
Torm Hustvet
Apex Trigger on Custom Account Team Object not Allowing Uploads
Hello,
I have an Apex trigger that is not allowing me to upload a custom account relationship object. Specifically line 19 appears within my upload tool (DemandTools and Dataloader). I am able to create these manually, but would like to better understand the purpose of the trigger below. Ideally, I may be able to disable it for the purposes of uploading.
Trigger Code:
I have an Apex trigger that is not allowing me to upload a custom account relationship object. Specifically line 19 appears within my upload tool (DemandTools and Dataloader). I am able to create these manually, but would like to better understand the purpose of the trigger below. Ideally, I may be able to disable it for the purposes of uploading.
Trigger Code:
trigger updateACCTBTTM on Baker_Tilly_Account_Team_Contacts__c (after insert, after update,before delete,after delete){
Set<Id> parentIds = new Set<ID>();
// Get all the Parent Ids (Accounts ) in the Set
for(Baker_Tilly_Account_Team_Contacts__c s : trigger.isDelete ? trigger.old : trigger.new){
parentIds.add(s.Account__c);
}
// QUery Account.
List<Account> accounts = new List<Account>();
// Use the Child relations so you get all the related AcctBTTM for the Account Parent Object
Accounts = [Select Id, Baker_Tilly_Account_Team_Contacts__c, (Select Id, Contact_Name__r.Name__c from Baker_Tilly_Account_Team_Contacts__r) from Account where Id in :parentIds];
// Iterate over each parent and child BTTM record
for(Account o: accounts){
o.Baker_Tilly_Account_Team_Contacts__c = '';
if(o.Baker_Tilly_Account_Team_Contacts__r != null && o.Baker_Tilly_Account_Team_Contacts__r.size()>0){
for(Baker_Tilly_Account_Team_Contacts__c s: o.Baker_Tilly_Account_Team_Contacts__r){
if(!o.Baker_Tilly_Account_Team_Contacts__c.containsIgnoreCase(s.Contact_Name__r.Name__c)){ // Check if the BTTM record is already in the BTTM Field. if not add it otherwise skip
o.Baker_Tilly_Account_Team_Contacts__c += s.Contact_Name__r.Name__c+' ';
}
}
}
}
// Update the account
update accounts;
}