Activity › Forums › Salesforce® Discussions › How do I convert a list to a map in Salesforce? Salesforce® Discussions How do I convert a list to a map in Salesforce? Posted by Marziya on September 7, 2020 at 1:33 PM How do I convert a list to a map in Salesforce? Anuj replied 5 years, 8 months ago 3 Members · 2 Replies 2 Replies Kirandeep Member September 7, 2020 at 1:41 PM Hi Marziya, You can convert like this :- List<Account> AccList = new List<Account>(); Map<Id,Account> AccMap = new Map<Id,Account>(); for(Account acc :AccList) { AccMap.put(acc.id,acc); } [adinserter block='9'] Anuj Member September 7, 2020 at 1:54 PM Converting List to Map: //Converting list to map. Map<Id, Lead> mapFromList = new Map<Id, Lead>(leadList); Log In to reply. Public All Members My Connections Only Me PublicAll MembersMy ConnectionsOnly Me Public All Members My Connections Only Me