Write a trigger on Account Whenever New Account Record is created, then needs to create associated Contact Record Automatically with Account name as Contact LastName and Account Phone as Contact Phone in Salesforce | Apex Trigger Create Related Contact whenever new Account is created in Salesforce

Vijayk
3 min readJul 30, 2022

Hey guys, today in this post we are going to learn about how to Write a trigger on Account Whenever New Account Record is created, then needs to create associated Contact Record Automatically with Account name as Contact LastName and Account Phone as Contact Phone in Salesforce.

What is the use of Apex triggers?

Apex triggers enable you to perform custom actions before or after events to records in Salesforce, such as insertions, updates, or deletions. Just like database systems support triggers, Apex provides trigger support for managing records.

Final Output → To get source code live demo..

Other related post that would you like to learn in Salesforce

Create Apex Trigger →

Step 1:- Create Apex Trigger : accountContactTrigger.apxt

From Developer Console >> File >> New >> Apex Trigger

accountContactTrigger.apxt [Apex Trigger]

Further post that would you like to learn in Salesforce FAQ (Frequently Asked Questions)

What is an apex trigger?

Apex triggers enable you to perform custom actions before or after changes to Salesforce records, such as insertions, updates, or deletions. A trigger is Apex code that executes before or after the following types of operations: insert. update.

What is the use of Apex triggers?

Apex triggers enable you to perform custom actions before or after events to records in Salesforce, such as insertions, updates, or deletions. Just like database systems support triggers, Apex provides trigger support for managing records.

Can we write two triggers on same object?

Writing multiple triggers renders the system unable to recognize the order of execution. Moreover, each trigger that is invoked does not get its own governor limits. Instead, all code that is processed, including the additional triggers, share those available resources.

Final Output → To get source code live demo..

Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Originally published at https://www.w3web.net on July 30, 2022.

--

--