You need to sign in to do that
Don't have an account?

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)
{
actNew.ShippingAddress=actNew.BillingAddress;
}
lstAccount.add(actNew);
}
insert lstAccount;
}
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)
{
actNew.ShippingAddress=actNew.BillingAddress;
}
lstAccount.add(actNew);
}
insert lstAccount;
}
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_account.htm
https://help.salesforce.com/apex/HTViewHelpDoc?id=account_fields.htm&language=en
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 triggger.new records. Please find the below code hope this will help you to solve your problem. Thanks,
Kapil
(forcecube@gmail.com)
mine is still showing error
trigger billingAddress on Account (after insert) {
for(Account a : Trigger.new){
a.ShippingAddress = a.BillingAddress;
a.ShippingCity = a.BillingCity;
a.ShippingCountry = a.BillingCountry;
a.ShippingPostalCode = a.BillingPostalCode;
a.ShippingState = a.BillingState;
a.ShippingStreet = a.BillingStreet;
}
}
you can direct to https://dfc-org-production.force.com/forums/ForumsMain?id=906F0000000kFBpIAM for answers.
Hope this helps!