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);

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...