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

Field is not writeable: Case.ContactMobile
trigger casePhone on Account (After insert,After update) {
for(Account a : trigger.new){
list<case> kca = New list<case>([select id,ContactMobile from case where ContactMobile != null And Accountid =: a.id]);
for(case ca : kca){
ca.ContactMobile = a.Phone;
}
}
}
for(Account a : trigger.new){
list<case> kca = New list<case>([select id,ContactMobile from case where ContactMobile != null And Accountid =: a.id]);
for(case ca : kca){
ca.ContactMobile = a.Phone;
}
}
}
If it solves the puzzle the please mark it best answer since it will help other users with similar issues!
Kishore, if you think the questionis solved the would you mind marking it best answer since it will help our community users!
Appreciated!
Is it Contact_Mobile__c ?
Hope it help!
I think you want to update the ContactMobile (Contact Mobile) field of case object but this is a standard field and it actually refers to Contact's MobilePhone (Mobile) field. If you update the MobilePhone(Mobile) field of Contact then it automatically update the ContactMobile field of Case. You don't need to write any code for this.
Hence for this scenario you need to update the MobilePhone field of Contact and it automatically update ContactMobile of Case.
Find the code below:
trigger casePhone on Account (After insert,After update) {
list<case> kca = New list<case>();
list<Contact> kcon = New list<Contact>();
list<Contact> lstConupdate = New list<Contact>();
Set<Id> cas = new Set<Id>();
for(Account a : trigger.new){
kca = [select ContactId, Contact.MobilePhone from case where ContactMobile != null and Accountid =: a.id];
for(Case cs: kca){
cas.add(cs.ContactId);
}
kcon = [select id,MobilePhone from Contact where id in: cas];
for(Contact ca : kcon ){
ca.MobilePhone = a.Phone;
lstConupdate.add(ca);
}
}
update lstConupdate;
}
But if you dont want to update contact's Mobile number then you can create a custom formula field in case.
Thanks
Preyanka