User Story
As a sales representative for ABC Company, I want to ensure that any time a new Account record is created in Salesforce, an associated Contact record is automatically created. This will help me save time and ensure that all necessary records are created in a timely and accurate manner.
Code
Apex Trigger
trigger CreateAssociatedContact on Account (after insert) {
List<Contact> newContacts = new List<Contact>();
for (Account newAccount : Trigger.new) {
Contact newContact = new Contact();
newContact.FirstName = 'New Contact';
newContact.LastName = 'Automatically Created';
newContact.AccountId = newAccount.Id;
newContacts.add(newContact);
}
insert newContacts;
}