Paul’s Salesforce Blog

What’s new with Salesforce?

Import Object Data Directly into a Map

Posted by paulovery on January 29, 2014

Here’s a neat trick that I found.  You can use it to import object data directly into a Map, indexed by the Object’s ID.

Here is an example:

Map<ID,Contact> contactMap = new Map<ID,Contact>([select id, name, phone, email from contact]);

 

This will import the results of the SOQL query directly into the Map!

 

I hope you find this as useful as I do.

One Response to “Import Object Data Directly into a Map”

  1. SutoCom said

    Reblogged this on Sutoprise Avenue, A SutoCom Source.

Leave a comment