How do I create a trigger, to update a field on Account, when the contact, related to this account changes the field.
Example--- If a contact has a mailingcity, the respective Account Mailing city field should updated with the same value
My Trigger is as follows
But its not working Illegal assignment from Schema.SObjectField to String
The code what i have written is also from google. I am not able to solve this. Please help
trigger ContactToAccountAddress on Contact (after insert,after update) {
List<ID> AccID = New List<ID>();
for(Contact con : Trigger.new){
if(con.MailingCity!=null&& con.AccountId != null){
AccID.add(con.AccountId);
}
}
List<Account> accList = [SELECT Name, BillingStreet FROM Account WHERE id in :AccID];
for(integer i = 0 ; i < accList.size(); i++){
accList[i].BillingStreet =Contact.MailingCity;
}
update accList;
}