January 2019 archive

Salesforce Collections : Map from SOQL

There must have been times when creating a map from a SOQL is required. I am showing 2 ways of doing the same. Map from List ( obtained from SOQL)Map<Id, CustomObj__c> myMap = new Map<Id, CustomObj__c>();for(CustomObj__c objCS : [Select Id Name,Status__c From CustomObj__c ]){myMap.put(objCS.Id, objCS);                     …

Continue reading

Permanent link to this article: https://salesforcebuddy.com/2019/01/salesforce-collections-map-from-soql/

Salesforce Collections – Maps

Maps are pretty useful and can make your code more readable and efficient. In particular, maps can be instantiated in a number of ways. Here is the standard way of instantiating a map: Map<Id, Account> accountsById = new Map<Id, Account>(); However, if you happen to have a list of sObjects you can just pass that …

Continue reading

Permanent link to this article: https://salesforcebuddy.com/2019/01/salesforce-collections-maps/