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
Vinicius Vandre 5Vinicius Vandre 5 

How to set custom field values in Account for Lead conversion ?

I'm trying to use Database.leadConvert to set Account fields based on a condition, as such: 

 Database.LeadConvert lc= new Database.LeadConvert();
        lc.setLeadId(lead.Id);
        lc.setConvertedStatus('Closed-Converted');
        lc.accountrecord.CustomField = 'Value';
        Database.leadConvertResult lcr = Database.convertLead(lc);


However I get a "Variable does not exist: CustomField" Error.

How would I go about achieving the task using Database.LeadConvert  class?

Huge thanks in advance
 

VinayVinay (Salesforce Developers) 
HI Vinicius,

Check below reference that can help you.

https://salesforce.stackexchange.com/questions/370449/how-to-set-custom-field-values-in-account-for-lead-conversion

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,