Below Example explains how we can add multiple Account Records in AccountList and Insert
All of them.
Example 1:-
List<Account> AccInsert = new List<Account>(); for( Integer i=0;i<=10;i++){ Account Acc = new Account(); Acc.Name = 'Account'+'=='+ i ; AccInsert.add(Acc); } Insert AccInsert;
Example 2:-
List<CaseShare> csShareList = new List<caseShare>(); for(User usrInstance:[Select ID FROM USER WHERE ISACTIVE = TRUE AND ProfileId ='00e5C000000DeBi']){ CaseShare csShare = new CaseShare();//this should be in for loop csShare.CaseId ='5005C000001TPOD'; csShare.UserOrGroupId = usrInstance.Id; csShare.CaseAccessLevel = 'edit'; csShareList.add(csShare); } Insert csShareList;
No comments:
Post a Comment