You need to sign in to do that
Don't have an account?
![Vijay@sfdc Vijay@sfdc](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Empty debug statement
Hello All,
Public Class AccountCreation
{
Public List<Account> CreateAccount(String s, String p){
List<Account> a = new List<Account>();
for(Account acc:a)
{
acc.Name=s;
acc.phone=p;
insert all;
}
return a;
}
In the above programm , can crete account , but i am not getting rerun values after i executed bellow code in developer console
AccountCreation ac= new AccountCreation();
ac.CreateAccount('sss','1234');
System.debug("debug"+ ac);
in this debug statement not displaying any created records.
would any one please explain bit more what might be the reason .
Public Class AccountCreation
{
Public List<Account> CreateAccount(String s, String p){
List<Account> a = new List<Account>();
for(Account acc:a)
{
acc.Name=s;
acc.phone=p;
insert all;
}
return a;
}
In the above programm , can crete account , but i am not getting rerun values after i executed bellow code in developer console
AccountCreation ac= new AccountCreation();
ac.CreateAccount('sss','1234');
System.debug("debug"+ ac);
in this debug statement not displaying any created records.
would any one please explain bit more what might be the reason .
1. Why you are using for loop to insert account. As there is no value in 'a'(list your initializing just before for loop a.size() will be zero).
2. if you want to display return value in debug, first you have to store it.
Please see below code of Apex class:
Developer Console :
Please check.
Thanks,
Vedashri
All Answers
1. Why you are using for loop to insert account. As there is no value in 'a'(list your initializing just before for loop a.size() will be zero).
2. if you want to display return value in debug, first you have to store it.
Please see below code of Apex class:
Developer Console :
Please check.
Thanks,
Vedashri
You are initializing the list "a" just above the for loop so this list will never contain any records in it and hence the code written inside the for loop will never execute because the "a" list is empty.
I have updated your code. Please try with below code :
Please let me know if you need more information or help on this.
Thanks,
Abhishek Bansal