Write a trigger in Apex that updates the Opportunity .. | www.sfdctelugu.in

Write a trigger in Apex that updates the Opportunity stage to "Closed Won" when the Opportunity amount is greater than or equal to $10,000.


Explanation:

This is a trigger on the Opportunity object that fires before records are inserted or updated. It loops through all the records in the Trigger.new list, which contains the records being inserted or updated.

The if statement checks if the Opportunity's amount is greater than or equal to $10,000 and if the stage name is not already "Closed Won". If both conditions are true, the stage name is updated to "Closed Won".

The trigger is defined with the before keyword, which means the changes made to the records in the loop will be saved to the database. The trigger is also defined for both insert and update events, so it will fire whenever a record is created or updated.

Finally, this trigger ensures that Opportunities with a high enough amount are automatically marked as "Closed Won" to simplify the sales process.

For Salesforce Videos: SFDC TELUGU | Subscribe.

 e-Book Store

S F D C  T e l u g u

Steps:
  1. Click on eBook
  2. Fill the Details (mail id must be correct)
  3. Select Payment method
Note: 
  • you will get eBook pdf given Gmail id within 0-2 hours.












Thank you,
SFDC e-BOOK STORE.

Post a Comment

0 Comments