You need to sign in to do that
Don't have an account?
christin mathew
Whenever a new contact is created for a account update the corresponding account phone with the new contact??
Whenever a new contact is created for a account update the corresponding account phone with the new contact??
trigger updatephonenocontact on Account (After insert) {
List <Contact> Con = new List <Contact>();
For (Account A: Trigger.new){
Contact C = new Contact();
C.phone= A.phone;
C.AccountId = A.Id;
Con.add(C);
}
Insert Con;
}
im getting this error message
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger updatephonenocontact caused an unexpected exception, contact your administrator: updatephonenocontact: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Last Name]: [Last Name]: Trigger.updatephonenocontact: line 19, column 1
trigger updatephonenocontact on Account (After insert) {
List <Contact> Con = new List <Contact>();
For (Account A: Trigger.new){
Contact C = new Contact();
C.phone= A.phone;
C.AccountId = A.Id;
Con.add(C);
}
Insert Con;
}
im getting this error message
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger updatephonenocontact caused an unexpected exception, contact your administrator: updatephonenocontact: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Last Name]: [Last Name]: Trigger.updatephonenocontact: line 19, column 1
Just do an after update on the Contact and get the account and update it.
In fact - you might be able to take care of it with a field-update workflow rule. Might have to think about that for a minute.
I think that's the bulkified code you'll need. Not 100% sure on the syntax, and on the field name for PhoneNumber