You need to sign in to do that
Don't have an account?

Compile Error
Error: Compile Error: Return value must be of type: LIST<Account> at line 4 column 9 <-- this is the error i get when i try to run the following code:
public class MyController {
public List<Account> getMyAccounts ()
{
return [select Id, Name, Accountnumber from Account
Order by LastmodifiedDate DESC Limit 10];
}
}
please let me know where i went wrong. Thank you.
You aren't explicitly returning a List<>. Try this:
All Answers
You aren't explicitly returning a List<>. Try this:
i tried this code, but it's still giving me a compile error:
Error: Compile Error: Return value must be of type: LIST<Account> at line 4 column 9
I am following a VF tutorial for this. The first thing i did was create a VF page with the following code:
<apex:page controller="MyController">
<apex:form>
<apex:dataList value="{!myaccounts}" var="acct">
<apex:outputText value="{!acct.name}"></apex:outputText>
</apex:dataList>
</apex:form>
</apex:page>
Then I had SF create a public sharing class called MyController for me and create apex method getmyaccounts. The next thing i did was click on the controller tab and enter the following code:
public with sharing class MyController {
public List<Account> getMyAccounts () {
return [select Id, Name, Accountnumber from Account ORDER BY
LastModifiedDate DESC LIMIT 10];
}
}
thats when i got the error.
Hello friend,
You just need to modify the code as below
Hope this helps
Regards
Raumil Setalwad
Nothing is wrong here . I tried the same code in my org and I was able to compile it.
which code did you try?
sorry i clicked the accept as solution button by accident...
I tried this code and I am still getting the same error message.
I am sorry its my mistake
Also check the following link for <apex:datalist> command
Hope this helps
Regards
Raumil Setalwad
I am still trying to figure out what is above. Please give the Controller and VF page at its entire.
Thanks
Just check your all apex classes, by mistake you created the class of Account. So firstly delete that class and then save your code.
I think that it will solve your problem.
Thanks,
Geeta