You need to sign in to do that
Don't have an account?
SfDeveloper
How to get and print id's when inserting multiple records in apex class?
List<Account> accountList = new List<Account>();
for(integer i=1; i<=10; i++){
Account a = new account();
a.name ='sha'+i;
a.phone='123323240'+i;
a.annualrevenue=9096; accountList.add(a);
}
insert accountList;
I want to create a list of id's and print thought system.debug . how to do this?
for(integer i=1; i<=10; i++){
Account a = new account();
a.name ='sha'+i;
a.phone='123323240'+i;
a.annualrevenue=9096; accountList.add(a);
}
insert accountList;
I want to create a list of id's and print thought system.debug . how to do this?
You can try the below code to get the list of inserted accounts by querying on the phone number. Hope this helps. Kindly mark it as best answer if it solves your question.
Thanks,
Karthik