- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- 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
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.
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".
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)
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.