function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anshuman ParhiAnshuman Parhi 

4. Write code for following: After an Account record is created, create a Contact record linked to that Account record. [Restriction: Cannot use apex trigger for this]

Any solution....Thanks in advance
ANUTEJANUTEJ (Salesforce Developers) 
Hi Anshuman,

>> https://www.youtube.com/watch?v=pgimn2RnYv0

>> https://trailblazers.salesforce.com/answers?id=9063A000000pJzxQAE

The above two links create a child record from flows you can try checking these implementations and modify them to fit your use case.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Suraj Tripathi 47Suraj Tripathi 47
Hi Anshuman,
Greetings!
trigger CreateContact on Account (after insert) {
    List<Contact> conList = new List<Contact>();
    for(Account acc : trigger.new) {
        Contact con = new Contact();
        con.LastName = acc.Name;
        con.AccountId = acc.Id;
        conList.add(con);
    }
    if(!conList.isEmpty()) {
        INSERT conList;
    }
}
If you find your Solution then mark this as the best answer. 
Thank you!
Regards,
Suraj Tripathi
mukesh guptamukesh gupta
Hi Anshuman Parhi,

You can use process buider on Account Creation time and associate account with New contact record.

if you need any assistanse, Please let me know!!


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
Anshuman ParhiAnshuman Parhi
Hello

Can we create this by apex code only..... not using trigger,proess builder or anything else
Suraj Tripathi 47Suraj Tripathi 47
If you want to create a contact automatically when after the account is created.
This is called an automated process.
In salesforce, for implementing the automation, we have to use Trigger, Process builder, Workflow, Flows, Schedulable, etc.
Without these, we can not automate using apex code.

So I use trigger here.

Thanks and Regards
Suraj Tripathi.