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 › How to store list of contacts in Salesforce associated to a particular account using Map?

    Tagged: Account, Contact List in Salesforce, Contact Record, Map FinalMap, Map in Salesforce, Salesforce Query, Salesforce sObject

    • Salesforce® Discussions

      How to store list of contacts in Salesforce associated to a particular account using Map?

      Posted by subramanyam subbu on January 10, 2018 at 3:23 AM

      Can you please tell me the query how to store a list of contact associated with an account using Map
      Iam using this below query
      Map FinalMap=new Map[(Select id,(Select lastname from contacts) from account)];

      Throughing errror you cannot store two sobject on a map

      Ajay Prakash replied 8 years ago 2 Members · 1 Reply
      • Account
      • Contact List in Salesforce
      • Contact Record
      • Map FinalMap
      • Map in Salesforce
      • Salesforce Query
      • Salesforce sObject
    • 1 Reply
    • Ajay Prakash

      Member
      January 10, 2018 at 4:30 AM

      Hi subramanyam,

      Use below code, it will provide you a map of Account vs list of associated contacts.

      map<Account,list<Contact>> mapOfAccountVsContact = new map<Account,list<Contact>>();
      for(Account accObj : [select id, name, (select id,lastname from contacts) from Account]){
      mapOfAccountVsContact.put(accObj,accObj.Contacts);
      }
      system.debug('mapOfAccountVsContact::'+mapOfAccountVsContact);

    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

    Einstein Analytics

    Einstein Analytics: Data Sync Functionality Explained

    Blog in Analytics, Salesforce Einstein

    Data Sync is a process that helps to ensure that the data in your Salesforce org is ready to be used in Einstein Analytics. This…

    Channels, Connection Mode, Data in Einstein Analytics, Data Sync, Dataflow Run
    Anjali Mar 9, 2021
    3,628  Views
    Salesforce Einstein: The Beacon of Business Growth

    Salesforce Einstein: The Beacon of Business Growth

    Blog in Salesforce

    Businesses need more than just the right services and products to stand out in the market. Strategical use of data is paramount to promote quality…

    automation tools, Business Growth, Business Intelligence, Business Intelligence Tools, Competitive Advantage
    Carol Sep 2, 2024
    722  Views

    Top 10 Job Profiles for Salesforce Certified Professionals

    Blog in Salesforce Training

    Salesforce is one of the most used and popular CRM software that is best known to manage customer information. It is being used across a…

    Dashboards in Salesforce, DATA.com, Desk.com, Development Lifecycle And Deployment Designer, Force.com
    Vikas Dec 22, 2018
    5,540  Views

    Popular Salesforce Videos

    5 Mind-Blowing New Salesforce Marketing Cloud Releases

    5 Mind-Blowing New Salesforce Marketing Cloud Releases

    Video in Marketing, Salesforce Cloud Platform

    The Statist worldwide marking survey reports- “Almost 4 billion world population is digitally active, and 2.14 of them are shopping online.” In this entire scenario,…

    Artificial Intelligence, Salesforce Marketing Cloud, Customer Engagement, Internet of Things, Salesforce Video
    Algoworks Feb 23, 2021
    2,006  Views
    Exploring Technology Choices For Salesforce Integration

    Exploring Technology Choices For Salesforce Integration

    Video in Others

    Are you struggling to find the perfect technology to integrate Salesforce into your business processes? Integrating Salesforce into your business processes can offer significant advantages,…

    salesforce, Salesforce Video, Salesforce VIdeos, salesforceintegration, salesforcepartner
    Cyntexa Oct 23, 2023
    867  Views
    Salesforce for Beginners | Getting Started with Salesforce and CRM

    Salesforce for Beginners | Getting Started with Salesforce and CRM

    Video in Salesforce Training

    Chapter 1 of Salesforce for Beginner. It includes the following topics: 00:11 Login and Navigation 00:31 App launcher 00:48 Search 01:15 List Views 02:23 Salesforce…

    Salesforce Training, Salesforce Chatter, salesforce, CRM, Salesforce Video
    Prafull Jul 2, 2020
    1,988  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

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