0

I am using Database.Leadconvert to convert lead into account and Opportunity. So while converting there is validation in account object for a custom field, that we need to pass Business type while creating account

  List<Database.LeadConvert> massLeadConvert=new List<Database.LeadConvert>();

        for(Id currentLead:LeadIds){

            Database.LeadConvert LeadConvert=new Database.LeadConvert();
            LeadConvert.setLeadId(currentLead);
            LeadConvert.setOwnerId('0053z00000HCRRlAAP');
            LeadConvert.setConvertedStatus(cLeadStatus.MasterLabel);
            LeadConvert.setDoNotCreateOpportunity(false);
            massLeadConvert.add(LeadConvert);

        }

In the above code I need to pass that custom field while creating account so I tried in this way

Map<String, Object> accountFieldMap = new Map<String, Object>();
accountFieldMap.put('BusinessType__c', 'Group');
LeadConvert.setAccountFieldMap(accountFieldMap);

But I am getting method does not exist error and seems its deprecated.

I dont want to create a custom field in Lead object and map that field to account because depends on this Businesstype field there are some other validation rule also on account saying if Business type is 'Group' then there is a field named Known name which must not be empty. So cant't all custom fields in Lead which ever is necessary for Account.

Is there a way we can set custom field values during Database.Leadconvert?

1 Answer 1

1

Short answer - NO. There are no methods on leadConvert to pass in arbitrary values

To pass values usable in an Account Validation rule, you'll need to map a field on Lead to a field on Account. The fields can be hidden from the page layout so users never see.

  • The field on Lead can be a formula field or set by prior automation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .