• Almejas Almejas
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
There is a current trigger for Property Object for new records created in Salesforce that will check the address in Zillow (API)  and then update the field Parcel ID when the address is located. However, when I use dataloader for new records bulk upload, this trigger isn't firing. I still have to manually update each Property and refresh for the trigger to fire. Can you please help me with how I can fix this to work on bulk uploads?

Here is the PropertyHandler trigger that I can see in Dev Console:

public class PropertyDetailsHandler {
    public static Integer counter;
    static {
        counter = 1;
    }
    
    public static void checkAddress(List<Property_Details__c> newList, List<Property_Details__c> oldList){
        Set<Id> udpatedList = new Set<Id>();
        for(Integer i=0; i< newList.size(); i++){
            if(newList[i].Street_Address__c != oldList[i].Street_Address__c 
               ||
               newList[i].Unit_Number__c != oldList[i].Unit_Number__c 
               ||
               newList[i].State__c != oldList[i].State__c 
               ||
               newList[i].City__c != oldList[i].City__c
               ||
               newList[i].Postal_Code__c != oldList[i].Postal_Code__c){
                   udpatedList.add(newList[i].Id);
                   updateName(newList[i]);
                       
               }
        }
        if(udpatedList.size() > 0){
            
            if(System.Label.Is_Zillow_Active == '1' || Test.isRunningTest()){
                ZillowController.updateFromZillow(udpatedList);
            }
            if(System.Label.Is_Zillow_Active == '0'){
                BridgeController.updateFromBridge(udpatedList);
            }
        }
    }
    
    public static void updateName(Property_Details__c prop){
        prop.Name = '';
        if(prop.Street_Address__c != null &&prop.Street_Address__c != ''){
            prop.Name =prop.Street_Address__c;
        }
        if(prop.Unit_Number__c  != null &&prop.Unit_Number__c != ''){
            if(prop.Name != ''){
                prop.Name += ', #' +prop.Unit_Number__c; 
            }
        }
        
        if(prop.City__c  != null && prop.City__c != ''){
            if(prop.Name != ''){
                prop.Name += ', ' + prop.City__c; 
            }
        }
        
        if(prop.State__c  != null && prop.State__c != ''){
            if(prop.Name != ''){
                prop.Name += ', ' + prop.State__c; 
            }
        }
        
        if(prop.Postal_Code__c  != null && prop.Postal_Code__c != ''){
            if(prop.Name != ''){
                prop.Name += ' ' + prop.Postal_Code__c; 
            }
        }
        if(prop.Name != '' && prop.Name.length() >80){
            prop.Name = prop.Name.left(80);
        }
    }
}
 
There is a current trigger for Property Object for new records created in Salesforce that will check the address in Zillow (API)  and then update the field Parcel ID when the address is located. However, when I use dataloader for new records bulk upload, this trigger isn't firing. I still have to manually update each Property and refresh for the trigger to fire. Can you please help me with how I can fix this to work on bulk uploads?

Here is the PropertyHandler trigger that I can see in Dev Console:

public class PropertyDetailsHandler {
    public static Integer counter;
    static {
        counter = 1;
    }
    
    public static void checkAddress(List<Property_Details__c> newList, List<Property_Details__c> oldList){
        Set<Id> udpatedList = new Set<Id>();
        for(Integer i=0; i< newList.size(); i++){
            if(newList[i].Street_Address__c != oldList[i].Street_Address__c 
               ||
               newList[i].Unit_Number__c != oldList[i].Unit_Number__c 
               ||
               newList[i].State__c != oldList[i].State__c 
               ||
               newList[i].City__c != oldList[i].City__c
               ||
               newList[i].Postal_Code__c != oldList[i].Postal_Code__c){
                   udpatedList.add(newList[i].Id);
                   updateName(newList[i]);
                       
               }
        }
        if(udpatedList.size() > 0){
            
            if(System.Label.Is_Zillow_Active == '1' || Test.isRunningTest()){
                ZillowController.updateFromZillow(udpatedList);
            }
            if(System.Label.Is_Zillow_Active == '0'){
                BridgeController.updateFromBridge(udpatedList);
            }
        }
    }
    
    public static void updateName(Property_Details__c prop){
        prop.Name = '';
        if(prop.Street_Address__c != null &&prop.Street_Address__c != ''){
            prop.Name =prop.Street_Address__c;
        }
        if(prop.Unit_Number__c  != null &&prop.Unit_Number__c != ''){
            if(prop.Name != ''){
                prop.Name += ', #' +prop.Unit_Number__c; 
            }
        }
        
        if(prop.City__c  != null && prop.City__c != ''){
            if(prop.Name != ''){
                prop.Name += ', ' + prop.City__c; 
            }
        }
        
        if(prop.State__c  != null && prop.State__c != ''){
            if(prop.Name != ''){
                prop.Name += ', ' + prop.State__c; 
            }
        }
        
        if(prop.Postal_Code__c  != null && prop.Postal_Code__c != ''){
            if(prop.Name != ''){
                prop.Name += ' ' + prop.Postal_Code__c; 
            }
        }
        if(prop.Name != '' && prop.Name.length() >80){
            prop.Name = prop.Name.left(80);
        }
    }
}