You need to sign in to do that
Don't have an account?

Lead to Opportunity Trigger
Guys, i'm pretty new to apex and development on Salesforce, I'm trying to build a trigger where it populates the field Fase_Ciclo_vida__c on lead with current the stagename on Opportunity.
Anything i'm missing?
trigger OpportunityAfter on Opportunity (after insert, after update) { if (LibCommonFunctions.isTriggerStatusActive()) { if (trigger.isUpdate) { if (trigger.new.size() == 1) { if (trigger.new[0].IsWon) { Opportunity ls = [Select Id, StageName from Opportunity where IsWon=True]; if (trigger.new[0].ConvertedOpportunityId != null) { Lead o = [Select Id From Lead Where Id =: trigger.new[0].Id]; o.Fase_Ciclo_de_vida__c = ls.Stagename; update o; } } } } } }
Hi, Your question is seems to be incomplete. Since ConvertedOpportunityId is available on Lead when you are converting the lead into Account, opportunity and contact. I think you want to update opportunity field based on some field on lead. In that case you can write trigger on lead object after update and check for field isleadconverted on lead records.
Like : trigger leadconvert on Lead(after update) {
for(Lead led:trigger.new) {
if(led.isconverted==true){
// perform operation here
} } }
Regards -S