+ Start a Discussion
NyshaaNyshaa 

On creating a record in one object automatically a record should be created on the other object.

Create two Objects say Obj1(Parent) and Obj2(Child) having similar fields. On creating record of Obj1, associated Obj2 record should be created and vice versa. Additionally, updates should also be in sync i.e. updating the parent should reflect in the child and vice versa.
 

How can I achieve this requirement.

Thanks in Advance!

RituSharmaRituSharma
You may use process builder for this. Create process builder on both the objects to keep Obj1 and Obj2 in sync.
AbhishekAbhishek (Salesforce Developers) 
You can try this sample code,

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; 
}

It might help you.