Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Marketplace
    • Advertise With Us
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › Is it possible to run a SOQL Query and get a MAP returned?

    Tagged: Account, Apex Map, Salesforce Apex, Salesforce Query, SOQL

    • Salesforce® Discussions

      Is it possible to run a SOQL Query and get a MAP returned?

      Posted by Tanu on August 5, 2016 at 1:16 PM

      Is it possible to run a SOQL Query and get a MAP returned?

      Ajay Prakash replied 7 years, 11 months ago 3 Members · 2 Replies
      • Account
      • Apex Map
      • Salesforce Apex
      • Salesforce Query
      • SOQL
    • 2 Replies
    • Himanshu

      Member
      August 5, 2016 at 1:32 PM

      Hi Tanu,You can use the below query

      Map m = new Map([SELECT Id, Name FROM Account]);

    • Ajay Prakash

      Member
      January 13, 2018 at 3:16 PM

      Hi Tanu,

      Yes, You can run SOQL query and return into a map. You can refer below code it will return a map of Account id vs Account map-

      Map<id,Account> mapOfAccountIdVsAccount = new Map<Id,Account>([SELECT Id, Name FROM Account]);
      system.debug('mapOfAccountIdVsAccount::'+mapOfAccountIdVsAccount);

      Thanks.

       

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    application solution

    Popular Salesforce Blogs

    Validation Rules

    Validation Rules in Salesforce | A Brief Guide by Salesforce Developer

    Blog in Salesforce, Salesforce Apex

    The main purpose of using Salesforce validation rule verifies that the data a user enters in a record meets the standards you specify before the…

    Create Validation Rules, Custom Validation, Data Validation Rules, Description, Detailed Object List
    Alok Raj Sep 21, 2022
    2,861  Views
    Predictive Lead Scoring

    The Journey Towards Predictive Lead Scoring With Salesforce Einstein

    Blog in Salesforce Einstein

    What is Lead Scoring? Sales and marketing departments have actively started counting on lead scoring because it helps them save money and time by enabling…

    Artificial Intelligence, Customer Relationship Management, Einstein Account Insight, Einstein AI, Einstein Opportunity Insights
    Algoworks Apr 23, 2020
    2,456  Views

    Salesforce Service Cloud: Streamlining Customer Service Operations

    Blog in Salesforce Products

    Today's fiercely competitive business environment makes offering outstanding customer service more than simply a choice—it's a requirement. Customers now demand individualized, prompt, and effective service,…

    Applications, Automated Workflows, Best Practices, Case Management, Case Resolution Timelines
    Melonleaf May 25, 2023
    1,307  Views

    Popular Salesforce Videos

    Salesforce Apex Tutorial for beginners | Apex Salesforce Tutorial

    Salesforce Apex Tutorial for beginners | Apex Salesforce Tutorial

    Video in Salesforce Apex

    Apex is a proprietary language developed by Salesforce.com. It is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the…

    Salesforce Training, Salesforce Tutorial, Salesforce Apex, salesforce, Apex
    Prafull Jun 6, 2022
    2,418  Views
    Summer '20 Release - Release Updates Page

    Summer '20 Release - Release Updates Page

    Video in Others, Salesforce Stories

    Check out the new Release Updates Page. Salesforce Summer '20 is full of amazing features for #AwesomeAdmins! Check out what's new when you follow and…

    Salesforce Training, Salesforce Admin, Salesforce Video, Salesforce Learning, Summer 20
    Neha Yadav Jul 14, 2020
    1,320  Views
    Integrate Salesforce and Active Directory Step by Step

    Integrate Salesforce and Active Directory Step by Step

    Video in Salesforce Integration

    The prospect of implementing Single Sign-on in your Salesforce org can seem daunting if you are unfamiliar with the process. In this live step-by-step demo…

    Salesforce Integration, Cloud Computing, Enterprise Application Development, Salesforce Org, Salesforce Integration Cloud
    Portia Apr 16, 2018
    1,935  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2025 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.