Tuesday, 11 October 2016

How to convert List to Map in Salesforce

Here is the simple way to convert list of sobject records to map.

Assigning query result to List:

  1. //Assigning return query result to the list.
  2. List<Lead> leadList = [SELECT Id, Name FROM Lead];

Assigning query result to Map:

  1. //Directly assigning return query result to the map.
  2. Map<Id, Lead> leadMap = new Map<Id, Lead>([SELECT Id, Name FROM Lead]);

Converting List to Map:

  1. //Converting list to map
  2. Map<Id, Lead> mapFromList = new Map<Id, Lead>(leadList);

6 comments:

  1. very informative blog and useful article thank you for sharing with us , keep posting learn more aboutsalesforce training,salesforce online training

    ReplyDelete
    Replies
    1. best training institute to not only get job but to survive in job & be stable:
      www.salesforcestart.com

      Delete
  2. I have been searching to find a comfort or effective procedure to complete this process and I think this is the most suitable way to do it effectively. Garmin Map Update Download

    ReplyDelete
  3. A python training program provides complete knowledge from beginner to advanced levels. It includes structured lessons and practical examples. This python training improves coding efficiency and problem-solving ability. It focuses on real-world use cases. Students build functional applications. It is professional.

    ReplyDelete
  4. Best Tableau training helps learners analyze complex datasets and present insights through powerful dashboards. It explains forecasting and trend analysis clearly. This best tableau training strengthens data storytelling and visualization skills. Learners complete real-time projects. Industry examples are included. Expert mentorship is provided. It prepares successful BI careers.

    ReplyDelete

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...