• christin mathew
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
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
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