USER STORY
As a Salesforce user,
I want to be able to update an account,
So that all the opportunities associated with this account will automatically be updated, but only if the probability of those opportunities is greater than 50. This will help me ensure that I focus on high-potential opportunities and maintain accurate and relevant information in the system.
SOLUTION
trigger AccountTrigger on Account (after update) {
List<Opportunity> relatedOPPs = [SELECT Id, Name, Probability FROM Opportunity WHERE AccountId IN: Trigger.new];
List<Opportunity> updatedOPPList = new List<Opportunity>();
for(Opportunity opp : relatedOPPs){
if(opp.Probability >50 ){
opp.description ='The description is updated for the opportunities whose probability is more than 50: 2.';
updatedOPPList.add(opp);
}
}
update updatedOPPList;
}