0

Hi all new to Apex here completing Trailhead...

I am receiving the error in the title and can't seem to figure out why. Here's my apex class:

public class AccountHandler {
    public static void insertAccount(Integer value){
        Integer counter = 1;
        //create a list
        List<Account> addAccounts = new List<Account>();
        while(counter <= value){
        //display current counter value
        system.debug('Counter value before incrementing' + counter);
        //create a new account
        Account store = new Account();
        store.Name = 'Acme Inc n' + counter;
        store.AccountNumber = 'A00n' + counter;
        addAccounts.add(store);
        system.debug(addAccounts);
        //increment counter
        counter = counter + 1;
        system.debug('Counter value after incrementing' + counter);     
        
        }
        system.debug('Size of Account list:' + addAccounts.size());
        system.debug('Elements in Account List:' + addAccounts);
        //insert
        insert addAccounts;
    }
}

And here is my execution code:

AccountHandler.sObjectsInsert(3);

Any help is appreciated!

3

You are declaring a method insertAccount():

public static void insertAccount(Integer value){

but you are calling a method sObjectsInsert():

AccountHandler.sObjectsInsert(3);

You must change one or the other - either call the method as declared, or declare the method as called.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.