Create Related Opportunity on Account Creation

In Salesforce, one of the best ways to speed up your sales process is to automate predictable patterns—like creating an Opportunity as soon as a new Account is onboarded. This ensures that your pipeline stays active, no follow-up is forgotten, and your team never misses a potential sales conversation.

In this blog, we introduce a simple yet powerful Apex trigger that fires after an Account is created and automatically generates a related Opportunity with default values like:

  • Stage: Prospecting

  • Close Date: Today’s date

  • Opportunity Name: Account Name + “opp”

This automation is perfect for streamlining your lead-to-opportunity conversion process, improving efficiency, and maintaining consistent Opportunity records tied to every new Account.

🧠 Why Automating Opportunity Creation Is Smart


Sales teams often follow a set process: create an Account, then immediately log an Opportunity. But relying on users to always perform this second step leads to inconsistencies, missed deals, and delays in pipeline visibility.

By introducing this automation:

  • You eliminate the need for manual Opportunity creation

  • You ensure every new Account enters the sales pipeline instantly

  • You give managers a real-time view of upcoming opportunities

  • You reduce human error and improve data consistency

  • You build a foundation for further automation around Opportunity workflows

It’s a small improvement that delivers big gains in process efficiency and data reliability.

🔍 What This Blog Covers


  • How to use an after-insert Apex trigger to create related records

  • The importance of automating repeatable tasks for CRM consistency

  • How to set default values like StageName, CloseDate, and dynamic naming

  • The benefits of using trigger handler classes for maintainable logic

  • Real-world use cases where auto-creating Opportunities accelerates the sales cycle

This solution is not just for demo orgs or tutorials—it’s a practical automation you can implement in production environments with ease and confidence.

🎯 Perfect for These Use Cases


  • B2B companies where every client engagement starts with a formal Opportunity

  • Startups and SMBs looking to standardize their sales process from day one

  • Sales ops teams aiming to automate initial pipeline creation

  • Admins building smarter CRMs that work behind the scenes

  • Developers looking to create clean, reusable trigger logic

The pattern is flexible and can be expanded to include logic for default Opportunity amounts, lead source mappings, or even assigning sales reps based on Account criteria.

👨‍💻 Developer & Admin Tips


To avoid unnecessary data clutter, you may want to add filters—for example, only auto-create Opportunities for Accounts with specific record types or industries. You can also enhance the Opportunity naming convention to include region codes, sales teams, or other identifiers.

This automation becomes even more powerful when paired with reporting and dashboard components that rely on Opportunity creation timing and pipeline status.

For larger orgs or more complex processes, consider moving this logic to Queueable Apex or Platform Events if additional records need to be created asynchronously.

🎥 Watch It Happen – YouTube Playlist Linked

Want to follow along in real-time? We’ve added a YouTube playlist that walks through this entire example—from setting up the trigger to testing the Opportunity creation. Whether you’re hands-on in a sandbox or just getting started with Apex, this demo will make it click.

Solution:

trigger AccountTrigger on Account (after insert) {

              if(Trigger.isInsert){ if(Trigger.isAfter){
                          AccountTriggerHandler.createRelatedOpp(Trigger.New);
               }
        }
}

          public class AccountTriggerHandler {

          public static void createRelatedOpp(List<Account> accList){
                            List<Opportunity> oppList = new List<Opportunity> ();
                              for(Account acc: accList){
                                    Opportunity opp = new Opportunity(); opp.Name =
                                    acc.Name + ‘opp’; opp.AccountId = acc.Id;
                                   opp.StageName = ‘Prospecting’; opp.CloseDate =
                                   System.today(); oppList.add(opp);
               }
                         if(!oppList.isEmpty()){
                              insert oppList;
                       }
               }
         }
}

Want to Apply As Content Writer?

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart

Let's get you started!

Interested in writing Salesforce Content?

Fill in this form and we will get in touch with you :)