You need to sign in to do that
Don't have an account?
JaredPH
Help? Simple trigger to map lead type to standard opportunity type?
Hi everyone,
I'm terrible at coding, but was hoping someone would be feeling kind enough to help me with a simple trigger that maps the value of a custom lead field to the standard opportunity "type" field on conversion. The name of the field is lead_type__c
Any help that anyone could give would really be appreciated. Thanks so much!
I'm terrible at coding, but was hoping someone would be feeling kind enough to help me with a simple trigger that maps the value of a custom lead field to the standard opportunity "type" field on conversion. The name of the field is lead_type__c
Any help that anyone could give would really be appreciated. Thanks so much!
trigger trgUpdateType on Lead (before update) {
List<Lead> leads = Trigger.new;
Map<Id,string> oppids = new Map<Id,string>();
List<string> stropps = new List<string>();
for(Lead ld : leads)
{
if(ld.IsConverted)
{
oppids.put(ld.ConvertedOpportunityId,ld.Type__c);
stropps.add(ld.ConvertedOpportunityId);
}
}
List<Opportunity> opps = [select Type from Opportunity where Id IN: stropps];
for(Opportunity opp : opps)
{
opp.Type = oppids.get(opp.Id);
}
update opps;
}