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
Deepak Sharma 46Deepak Sharma 46 

Field is not writable :: actNew.ShippingAddress

Hi All,
Please help in resolving the field not writable issue being thrown in below code . The object and filed level sharing is being set appropriately

trigger AccountAddressTrigger on Account (before insert , before update) {
    System.debug('Welcome to the Triggers World');
    List<Account> lstAccount=new List<Account>();
    For (Account actNew :Trigger.New)
    if(actNew.BillingAddress !=NULL && actNew.Match_Billing_Address__c==true)
    insert lstAccount;
Yogesh KulkarniYogesh Kulkarni
Check the actual API names for different fields in documentation. Usually the fields are like ShippingStreet, ShippingCity etc. Check following URL
Hi Deepak,

There are some special fields in salesforce which constructs with other fields like address in your case. BillingAddress and shipping address get constructed with other fields like city, postalcode country etc. So you have to update these fields seprately.
Apart from that you are writing trigger so you can not insert or update the records which are part of the records. Please find the below code hope this will help you to solve your problem.
trigger AccountAddressTrigger on Account (before insert , before update) {
    System.debug('Welcome to the Triggers World');
	for (Account actNew :Trigger.New){
		if(actNew.BillingAddress != null && actNew.Match_Billing_Address__c == true){
			actNew.ShippingAddress = actNew.BillingAddress;
			actNew.ShippingCity = actNew.BillingCity; 
			actNew.ShippingCountry = actNew.BillingCountry;
			actNew.ShippingPostalCode = actNew.BillingPostalCode;
			actNew.ShippingState = actNew.BillingState;
			actNew.ShippingStreet = actNew.BillingStreet;
Thank you Kapil, it works !
Valteir JuniorValteir Junior
Thanks Kapil. You save my life !! 
Navaneeth SankarNavaneeth Sankar
Hi, Kapil 
mine is still showing error
trigger billingAddress on Account (after insert) {
    for(Account a :{
       a.ShippingAddress = a.BillingAddress;
       a.ShippingCity = a.BillingCity;
       a.ShippingCountry = a.BillingCountry;
       a.ShippingPostalCode = a.BillingPostalCode;
       a.ShippingState = a.BillingState;
       a.ShippingStreet = a.BillingStreet;

Ngô Hoàng DươngNgô Hoàng Dương
Hi, Navaneeth
you can direct to  for answers.
Hope this helps!