Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Really basic question
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Really basic question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 12:53 PM
I've literally been using Salesforce for about 30 minutes now, so this may be a pretty basic question. I'm trying to use an Apex class to retrieve a List of Accounts, like this:
List<Account> lstAccount = [select id, name from
System.debug('*** Number of Accounts: ' + lstAccou
But I'm never able to retrieve anything. I have a single account set up. Suggestions? Thanks.
Re: Really basic question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 12:57 PM
Nothing looks wrong so far. Maybe it's elsewhere? Could you post more code?
~ sfdcfox ~
I am a sandwich. That is all.
Re: Really basic question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 01:00 PM
Nothing more to post, that's the full extent of the method. If I don't use the list and just try something like:
Account a = [select id, name from Account LIMIT 1 ];
...then I get the dreaded "List has no rows for assignment to SObject".
Re: Really basic question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 06:22 PM
1) Is this a "test method"? If so, you need to make sure you create at least one account within the test method, or use "@isTest(SeeAllData=true)".
2) Is this an empty database? Make sure you've created at least one record.
3) Are you testing as a non-admin? Make sure sharing allows access (Setup > security > Sharing)
~ sfdcfox ~
I am a sandwich. That is all.
Re: Really basic question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 08:32 PM
yes, the error suggests you do not have any Account in your org. Developer editions have a few Accounts by default, FYI.
Or maybe the user who's running this code does not have access to Accounts.
Kudos a post if it helps, mark it as solution if it solves.
http://exploretheforce.blogspot.in
Re: Really basic question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-06-2013 03:52 AM
It is more likely that you do not have access to the account record. Try creating a few more, and run the query again.
- Anup

