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
Torm HustvetTorm 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:
Trigger Screenshot
 
Torm HustvetTorm Hustvet
Trigger Text if photo above does not work (line 19 underlined):

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;
}