trigger demoCreateOppOnAccount on Account (after insert) {
List<Opportunity> oppList = new List<Opportunity>();
for(Account a : trigger.new){
if(a.rating == 'Hot'){
Opportunity op = new Opportunity();
op.name=a.name;
op.AccountId = a.id;
op.StageName ='prospecting';
op.CloseDate = system.today()+15;
op.Type ='New Customer';
oppList.add(op);
}
}
insert oppList;
}
Description :- Whenever you create any account with Rating Hot, one new opportunity will be created under that account. If you want this logic to run when you edit any record with value Rating as Hot, then add the after Update event also
Kindly mark it as the best answer if it works for you.
You need to write a trigger for this.
Try this code :- Description :- Whenever you create any account with Rating Hot, one new opportunity will be created under that account. If you want this logic to run when you edit any record with value Rating as Hot, then add the after Update event also
Kindly mark it as the best answer if it works for you.
Thanks & Regards,
Priya Ranjan