function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

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!

Here you go:

trigger trgUpdateType on Lead (before update) {
List<Lead> leads =;
Map<Id,string> oppids = new Map<Id,string>();
List<string> stropps = new List<string>();
for(Lead ld : leads)
List<Opportunity> opps = [select Type from Opportunity where Id IN: stropps];
for(Opportunity opp : opps)
  opp.Type = oppids.get(opp.Id);
update opps;