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
swain 10swain 10 

Illegal assignment from SObject to Account

I want to create a instance of account to update some field related to that accountRecord during lead conversion.
I am getting Illegal assignment from SObject to Account. How to resolve that?

Account ac = lc.getAccountRecord();
Best Answer chosen by swain 10
Niraj Kr SinghNiraj Kr Singh
Hi Swain,
You can try this :
Account ac = (Account)lc.getAccountRecord(); //Typecast to Account

Hope it will help you.
Thanks
Niraj
 

All Answers

Niraj Kr SinghNiraj Kr Singh
Hi Swain,
You can try this :
Account ac = (Account)lc.getAccountRecord(); //Typecast to Account

Hope it will help you.
Thanks
Niraj
 
This was selected as the best answer
Amit Chaudhary 8Amit Chaudhary 8
Are your using LeadConvert Class? then use
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_convertLead.htm
getAccountId()

Gets the ID of the account into which the lead will be merged.
Signature
public ID getAccountId()

else do the type casting like below
Account ac = (Account)lc.getAccountRecord();

Let us know if this will help you