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
SIVASASNKARSIVASASNKAR 

Illegal assignment from LIST<Account> to LIST<Account> at line 9 column 5

When I run the following code i got error like 

 

"controllercls2 Compile Error: Illegal assignment from LIST<Account> to LIST<Account> at line 9 column5" 

 

And

 

When i insert out side of constructor " lst=[select id,name,phone from Account]; "

I got Error lik this

 

 

"Error: controllercls2 Compile Error: unexpected token: '=' at line 11 column 3 "

 

 

<apex:page controller="controllercls2" id="page">
<apex:form id="form">

<apex:outputlabel >Enter Text to search</apex:outputlabel>
<apex:inputtext />
<apex:commandButton value="Search" />
<apex:pageblock id="pb">
<apex:pageblocktable value="{!lst}" var="c">
<apex:column value="{!c.name}"/>
<apex:column value="{!c.phone}"/>
</apex:pageblocktable>


</apex:pageblock>
</apex:form>
</apex:page>

 

------------------------------------------

 

public with sharing class controllercls2 {

public List<Account> lst { get; set; }


public controllercls2()
{

lst=[select id,name,phone from Account];
}


}

 

Best Answer chosen by Admin (Salesforce Developers) 
JitendraJitendra

Hi Siva,

In your organization somewhere you have created a class named "Account". Thats why the compiler is not able to understand that it is standard Object Account or the class created by you. Please rename your class, it will work.

All Answers

JitendraJitendra

Hi Siva,

In your organization somewhere you have created a class named "Account". Thats why the compiler is not able to understand that it is standard Object Account or the class created by you. Please rename your class, it will work.

This was selected as the best answer
bob_buzzardbob_buzzard

That looks like lst doesn't contain Account sobjects.  Do you have a custom class named Account?  

bob_buzzardbob_buzzard

You also have the option of prefixing references to the account sobject with 'schema', e.g.

 

List<Schema.Account> lst;

  

(edited as I'd used contact rather than contact in one place).

JitendraJitendra

Thanks bob,

For nice information.

SIVASASNKARSIVASASNKAR

Thanks bob .......

 

 

 Yes i was used another class name as Account............ Thanks lot . I solve the problem with the help of SCHEMA

prashanthreddypalnatiprashanthreddypalnati

yep.....it works

Balakrishna MandulaBalakrishna Mandula

Thank you very much. It works for me...

sateesh57sateesh57

you are corrct.. I deleted account class from apex classes links.

 

Its works fine.

 

thank you.

 

 

sateesh57sateesh57
exactly correct
niranjan gniranjan g
hi bob with schema its working thanks great job
Minh NguyenMinh Nguyen


@bob_buzzard 
can you explain Schema.SomeSobject for me.
what does it mean  ? 

I found alot of your useful answer. thanks for you help . 

Ryuu HakukinRyuu Hakukin
Thank you very much