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? – Itai Shmida Sep 5 '16 at 7:11
  • I want to insert the 3 strings into 3 different accounts – Krishna Casukhela Sep 5 '16 at 7:16
  • 1
    @Tusharv answer!!! – Itai Shmida Sep 5 '16 at 7:18
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..... – Krishna Casukhela Sep 5 '16 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.