Skip to main content
pooja biswas 님이 #Apex에 질문했습니다
Hi

I have a List of string values, say 'a1','b1','c1'.

How to convert these string values into account object names

so finally I want to insert above values into account object.

please let me know.

 
답변 1개
  1. 2016년 9월 5일 오전 10:18
    Hi Pooja,

    If I understood your requirement correctly, you have a list of names & you want to use these names to create accounts. 

    1. you can write iterate over list, create an object instance,add it in list & insert it in end.

    Ex.

    List<String> accontNamesLst = new List<String>{'a1','b1','c1'};

    List<Account> accountsToInsert = new List<Account>();

    for(String strItr : accontNamesLst ){

    accountsToInsert.add(new Account(Name=strItr));

    }

    if(!accountsToInsert.isEmpty())

    insert accountsToInsert;

    Happy Coding!

    Regards,

    Amit Shingavi

          
0/9000