Create Sample Accounts in Your Org

To complete this exercise, add the following sample data in your org.
  1. Enter this code in the Source to execute field of the Execute Anonymous pane.
    1List<String> acctNames = new List<String>{
    2    'Ant Conglomerate',
    3    'Bee Collection Agency',
    4    'Beetle Brothers Body Shop',
    5    'Butterfly Beauty Supplies',
    6    'Flea LLC',
    7    'Fly Airlines',
    8    'Moth Candle Company',
    9    'Tick Timepieces',
    10    'Wasp Industrial Products',
    11    'Weevil Consultancy'
    12    };
    13
    14
    15List<Account> newAccts = new List<Account>();
    16
    17
    18for(Integer i = 0; i < 10; i++) {
    19    Account newAcct = new Account();
    20    newAcct.name = acctNames.get(i);
    21    newAcct.BillingCity = 'Suffragette City';
    22    newAccts.add(newAcct);
    23}
    24
    25
    26newAccts.get(0).rating = 'Warm';
    27newAccts.get(1).rating = 'Cold';
    28newAccts.get(2).rating = 'Hot';
    29newAccts.get(3).rating = 'Cold';
    30newAccts.get(4).rating = 'Cold';
    31newAccts.get(5).rating = 'Warm';
    32newAccts.get(6).rating = 'Hot';
    33newAccts.get(7).rating = 'Hot';
    34newAccts.get(8).rating = 'Cold';
    35newAccts.get(9).rating = 'Warm';
    36
    37
    38for (Integer i = 0; i < 10; i++) System.debug(newAccts.get(i));
    39insert newAccts;
  2. Click Execute Anonymous.

    If you get a compile error after executing this code, make sure that Account.rating is visible to your user. To give yourself access to the Account object’s Rating field, from Setup, enter Field in the Quick Find box, then click Account | Fields | Rating | Set Field-Level Security or Field Accessibility | Account | View by Fields | Rating.

    Note

  3. In the Accounts tab of the Salesforce user interface, verify that your accounts have been created.
    Congratulations. Your org now contains all the data that you need to complete the debugging exercise.