Auto-Update Opportunity Probability Based on Stage

Auto-Update Opportunity Probability Based on Stage

Business Requirement:

When an Opportunity’s Stage changes, automatically update its Probability (%) field to reflect the new stage value.

Example probability mapping:

  • Prospecting → 10%
  • Qualification → 30%
  • Proposal/Price Quote → 60%
  • Negotiation/Review → 80%
  • Closed Won → 100%
  • Closed Lost → 0%

This automation helps sales teams clearly understand deal chances and keeps data consistent.

Business Value:

  • ✔ Improves sales forecast accuracy
  • ✔ Removes need for manual probability updates
  • ✔ Enables better pipeline and opportunity management
  • ✔ Helps sales managers track deal health at a glance

🛠 Objects & Fields:

  • Opportunity
  • StageName (Picklist)
  • Probability (Percentage field)

Apex Trigger Code:

trigger UpdateProbabilityOnStageChange on Opportunity (before insert, before update) {
    for(Opportunity opp : Trigger.new) {
        if(opp.StageName != null) {
            switch on opp.StageName {
                when 'Prospecting' {
                    opp.Probability = 10;
                }
                when 'Qualification' {
                    opp.Probability = 30;
                }
                when 'Proposal/Price Quote' {
                    opp.Probability = 60;
                }
                when 'Negotiation/Review' {
                    opp.Probability = 80;
                }
                when 'Closed Won' {
                    opp.Probability = 100;
                }
                when 'Closed Lost' {
                    opp.Probability = 0;
                }
                when else {
                    opp.Probability = 0;
                }
            }
        }
    }
}

Example:

Opportunity stage changed to “Proposal/Price Quote” → Probability is automatically set to 60%.

Real-Time Use Cases:

  • Pipeline management for sales teams
  • Automated sales forecasting accuracy
  • Enforcing consistent data entry in Salesforce
📥 Download This as PDF

Leave a Comment

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

Scroll to Top