【TrailHead】システム管理者のためのオブジェクト指向プログラミング

【TrailHead】システム管理者のためのオブジェクト指向プログラミング

sObject と DML の使用

public class AccountHandler {
	// Public static method
    public static void insertAccount(Integer value) {
        Integer counter = 1;
        //create a list to add our accounts
        List<Account> addAccounts  = new List<Account>();
        try {
            while(counter <= value){
                //create a new account
            	Account acc = new Account();
                acc.Name = 'Acme Inc ' + counter;
                acc.AccountNumber = 'A000' + counter;
                
                addAccounts.add(acc);
                //increment the counter
            	counter = counter + 1;
            }
            //insert all of the accounts in the list
    		insert addAccounts;
		} catch (DmlException e) {
    			System.debug('A DML exception has occurred: ' +
                e.getMessage());
		}
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章