You need to sign in to do that
Don't have an account?
ramesh
auto lead convertion based on recordtype
trigger code need
record type id: 012Bg000000INcTIXX
when the stage will be 'converted - closed' auto generate account and contact and opportunity based on record type (in after insert & after update)
record type id: 012Bg000000INcTIXX
when the stage will be 'converted - closed' auto generate account and contact and opportunity based on record type (in after insert & after update)
I hope this Trigger Code will help you !!
trigger Leadconversiontrigger on Lead (After insert, After Update) {
List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
Set<ID> leadIds= new Set<ID>();
for(Lead leadRecord : trigger.new) {
if( leadRecord.Status == 'Closed - Converted' && leadRecord.isConverted == false){
leadIds.add(leadRecord.Id);
}
}
LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
for(id currentlead : LeadIds){
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId ( currentlead );
Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
Leadconvert.setDoNotCreateOpportunity(TRUE);
//you can remove this line if you want to create an opportunity during conversion
MassLeadconvert.add(Leadconvert);
}
if (!MassLeadconvert.isEmpty()) {
List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
}
}
If this code is helpful for you Please mark as Best answer!
Thank You.