0

I am having a list of string as follows:

List<String> str=new List<String>();
str.add('Post1');
str.add('Post2');
str.add('Post3');

I want to insert the above values into account object i.e account name=tcs and so on. I know I cant do it directly so I need help.

3
  • Your request is not clear - do you want to insert these 3 strings into 3 different accounts or the whole list into one account field? Sep 5, 2016 at 7:11
  • I want to insert the 3 strings into 3 different accounts Sep 5, 2016 at 7:16
  • 1
    @Tusharv answer!!! Sep 5, 2016 at 7:18

1 Answer 1

5

You can do something like

List<account> accList = new List<account>();
afor(string s : str)
{
  accList.add(new Account(Name = s));// fill other required fields as well
}
insert accList;
1
  • How come I missed this? Many thanks, its working..... Sep 5, 2016 at 7:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .