Since the address is a standard field, I'm assuming this process is pretty standard in setting it, but just in case, here's a very explicit explanation of how I'm updating it.
There are no standard fields on the Account for city, street, ZIP, etc...just the Address field. The only way to update this record in the interface is to double click the field area and it pops up with text fields for the street, city, ZIP, etc.
I want, on this update (After), to do other things. After some debugging, I found that when I update it and do system.debug(acc.BillingStreet), the street that I updated it to prints out correctly -- side note: BillingStreet doesn't appear on the list of standard fields...-- however, when I try system.debug(acc.BillingAddress), which should be all the components together, it's always null.
I can't imagine why it is null since it's the very thing that I'm updating. Here's the code for the trigger, but the issue has something to do with the address field, truly.
trigger udtInvAddress on Account (After Update) {
List<Order2__c> invoices;
System.debug('This should go, at the very least');
if(Trigger.isAfter){
if(Trigger.isUpdate){
//go through all of the accounts that this trigger effects
for(Account acc : trigger.new){
System.debug('HOW ABOUT THIS...?');
System.debug(acc.BillingStreet);
System.debug(Trigger.oldMap.get(acc.id).BillingStreet);
//separate all of the components of BillingAdress field in the account
Address addr = acc.BillingAddress;
System.debug('ADDR = ' + addr);
String AccountStreet;
String AccountCity;
String AccountState;
String AccountZip;
String AccountCountry;
//only update address if a new address is actually entered
if(addr != null){
System.debug('The address is not null, so assign values');
AccountStreet = addr.street;
AccountCity = addr.City;
AccountState = addr.state;
AccountZip = addr.postalcode;
AccountCountry = addr.country;
}
//Query to find all matching invoices
System.debug('IS THIS THE PROBLEM?');
invoices = [SELECT Billing_City__c, Billing_State__c, Billing_Street__c, Billing_zip__c, Billing_Country__c FROM Order2__c WHERE Account_Name__c =:acc.ID];
for(Order2__c invoice: invoices){
System.debug(invoice.ID);
//update all of the fields with the updated information only if the new information is filled in.
if(AccountCity <> null){
invoice.Billing_City__c = AccountCity;
}
if(AccountState <> null){
invoice.Billing_State__c = AccountState;
}
if(AccountStreet <> null){
invoice.Billing_Street__c = AccountStreet;
}
if(AccountZip <> null){
invoice.Billing_zip__c = AccountZip;
}
if(AccountCountry <> null){
invoice.Billing_country__c = AccountCountry;
}
}
}
}
update invoices;
}
}