+ Start a Discussion
Jake IrvinJake Irvin 

Field is not writeable SObjectException

I've been working on the trailhead training for apex triggers

However I keep getting an error in the developer console: "AccountAccess Trigger: Field is not writeable: Account.SippingAddress. I've scoured the forum but I haven't found anything that has been the answer to my problem. Thanks in advance for your help!
trigger AccountAddressTrigger on Account (before insert, before update) {
    for(Account a : Trigger.New) {
        if(NULL != a.BillingPostalCode && a.Match_Billing_Address__c == true){
			a.ShippingAddress = a.BillingAddress;
        }
    }
}

 
Best Answer chosen by Jake Irvin
@Karanraj@Karanraj
Address fields are compound data type, so when you adding values to standard address field then you have to write separately like street, city, postal code etc.,

Billing Address Field
  • BillingStreet
  • BillingCity
  • BillingState
  • BillingPostalCode
  • BillingCountry
  • BillingLatitude
  • BillingLongitude
Shipping Address Field
  • ShippingStreet
  • ShippingCity
  • ShippingState
  • ShippingPostalCode
  • ShippingCountry
  • ShippingLatitude
  • ShippingLongitude

All Answers

@Karanraj@Karanraj
Address fields are compound data type, so when you adding values to standard address field then you have to write separately like street, city, postal code etc.,

Billing Address Field
  • BillingStreet
  • BillingCity
  • BillingState
  • BillingPostalCode
  • BillingCountry
  • BillingLatitude
  • BillingLongitude
Shipping Address Field
  • ShippingStreet
  • ShippingCity
  • ShippingState
  • ShippingPostalCode
  • ShippingCountry
  • ShippingLatitude
  • ShippingLongitude
This was selected as the best answer
Jake IrvinJake Irvin
Ah thanks. My fault for not reading the trailhead instructions correctly :)