4

I would like to insert a bunch of sample account records (50 or so), without using the data loader. I have written code, but I do not know how to proceed. Where can I run it?

List<string> firstList = new List<string>{'fast', 'lunar', 'modern', 'super', 'retro', 'traditional'};
List<string> secondList = new List<string>{'car', 'cat', 'mining', 'office', 'computer', 'ship'};
List<Account> accountsList = new List<account>();

for (String first: firstList){
    for(string second: secondList) {
        Account a = new Account();
        a.Name = first + ' ' + second + ' co';
           accountsList.add(a);
    }
}

insert accountsList;
1
  • List<string> firstList = new List<string>{'fast', 'lunar', 'modern', 'super', 'retro', 'traditional'}; List<string> secondList = new List<string>{'car', 'cat', 'mining', 'office', 'computer', 'ship'}; List<Account> accountsList = new List<account>(); for (String first: firstList){ for(string second: secondList) { Account a = new Account(); a.Name = first + ' ' + second + ' co'; a.code__c = 'abc'; accountsList.add(a); } } insert accountsList; Mar 5, 2016 at 22:44

1 Answer 1

6

You will use the developer console to insert your apex.

To find the developer console, go to name-> Developer Console:

Enter image description here

Once you are in the developer console, click on menu Debug -> Open Execute Anonymous Windows:

Enter image description here

I see you are new to Apex and coding so get on to the Trailhead and get some training.

https://developer.salesforce.com/trailhead/en/apex_database/apex_database_intro

4
  • thanks, i was able to insert the records, after correcting the bug in my code. Mar 5, 2016 at 22:40
  • @user3520799 mark as answered so that others can find easily Mar 5, 2016 at 22:44
  • In the screenshot, menu command "Developer Console" appears to be in menu "mohit srivastav", not menu "Setup". What is correct? Mar 6, 2016 at 10:02
  • @peter great observation .just corrected!! Mar 6, 2016 at 10:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .