User Story
Crate an Apex trigger that will create a new opportunity when a lead is converted and the rating is "Hot":
Code
trigger CreateOpportunityOnLeadConversion on Lead (after insert, after update) {
List<Opportunity> oppList = new List<Opportunity>();
for (Lead l : Trigger.new) {
if (l.IsConverted && l.Rating == 'Hot') {
Opportunity opp = new Opportunity();
opp.Name = l.Name;
opp.StageName = 'Prospecting';
opp.CloseDate = Date.today().addMonths(3);
opp.AccountId = l.ConvertedAccountId;
opp.OwnerId = l.OwnerId; // Assign the Lead's OwnerId
oppList.add(opp);
}
}
insert oppList;
}
Video
Video does not exists.