Trigger 94: Auto-Close Opportunities as Closed Lost on Account Update

Опубликовано: 23 Апрель 2026
на канале: Salesforce by Sachdeva
59
8

#Salesforce #ApexTrigger #SalesforceDevelopment
In this Salesforce Apex Trigger (Trigger 94), we implement logic on the Account object. Whenever an Account record is updated, the trigger fetches all related Opportunities.

If any Opportunity meets the following conditions:

StageName is not equal to "Closed Won"

CloseDate is greater than 30 days old

Then, the trigger will automatically:

Update the StageName to "Closed Lost"

Set the CloseDate to today’s date

This automation helps maintain a clean and accurate sales pipeline by ensuring old opportunities are closed on time.

✅ A must-learn example for Salesforce Developers & Admins!


#SalesforceAdmin #SalesforceAutomation #Apex #CRM #Opportunities #AccountTrigger #ClosedLost #SalesforceLearning #SalesforceProjects #SalesforceInterviewQuestions