0

Whenever a new Account record is created, automatically a new contact record should be created.Need to use the instance of contact object and you can populate the required fields and ignore the rest.How to write a trigger to achieve this?

  • 2
    How would you capture the required fields for the Contact record, e.g. the Contact Name? Please explain more in the question - see the guidelines on how to ask How to Ask – Dave Humm Jun 20 '16 at 10:38
  • Please specify your requirement and have you tried to write the trigger. Please paste the code on which you get error. – Anurag Bhardwaj Jun 20 '16 at 10:39
  • 1
    why don't you just use process builder to create new records. this will be more simple to implement – Ratan Paul Jun 20 '16 at 12:23
  • I am just a beginner and thought I could get a proper help here through concepts but No ! people are busy in marking the question off topic ! – Sugandha Jun 20 '16 at 15:54
1

try this ,

I am not clear with your requirement but this can be achieve by trigger

For Eg:

trigger CreateAccountContact on Account (after insert, after update){

if(Trigger.isInsert){

    List<Contact> ct = new List <Contact>();

    for(Account acc : trigger.new){

        Contact c = new Contact(LastName = acc.name,
                    AccountId=acc.id,
                    Fax=acc.Fax,
                    MailingStreet=acc.BillingStreet,
                    MailingCity=acc.BillingCity,
                    /* similarly add all fields which you want */
                    MailingState=acc.BillingState,
                    MailingPostalCode=acc.BillingPostalCode,
                    MailingCountry=acc.BillingCountry,
                    Phone=acc.Phone);

        ct.add(c);
    }
    insert ct; 
}
|improve this answer|||||
  • Thanks ,but no new contact record was created ... – Sugandha Jun 20 '16 at 16:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.