Toggle Side Panel

  • Blogs
  • 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
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • 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
    • 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, 10 months 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

    Popular Salesforce Blogs

    Accelerate your business growth with Salesforce spring features

    Accelerate Your Business Growth In 2023 With Salesforce Spring ‘23 Release

    Blog in Salesforce

    The Salesforce Spring ’23 Release is packed with new features and enhancements that will help businesses streamline their operations, improve collaboration, and drive growth. One of the…

    Boost Revenue and Business, Business Decisions, Client Satisfaction, CRM, CRM Development & Implementation
    Variance InfoTech Mar 21, 2023
    1,537  Views
    Account-based Marketing

    All About Account-based Marketing in Salesforce

    Blog in Salesforce

    Understanding Account-based Marketing Account-based showcasing may be a B2B showcasing technique that centers on particular clients or accounts and targets each as an advertisement of…

    B2B Displaying, B2B Showcasing Technique, Businesses, Clients or Accounts, Companies
    Anjali Oct 13, 2020
    4,510  Views

    Understanding The True Potential of Salesforce Integration With SAP

    Blog in Salesforce integration

    Being one of the most popularly used customer relationship management (CRM) software in the market, Salesforce offers multitudes of functionalities towards managing critical business processes…

    Bbusiness Processes, Business Sales, Business System Environment, Businesses Optimize, Buusiness Functions
    Softweb Aug 27, 2020
    2,595  Views

    Popular Salesforce Videos

    An Introduction to Salesforce org Nonprofit Cloud

    An Introduction to Salesforce org Nonprofit Cloud

    Video in Salesforce For Nonprofits

    Did you know that over 30,000 nonprofit organizations use Salesforce? Salesforce.org’s premier product, NPSP, helps nonprofits drive greater impact by connecting everything they do. Learn…

    Salesforce Developer, Salesforce Lightning Experience, Salesforce Implementation, Marketing Automation, Salesforce CRM
    Pooja Nov 21, 2018
    3,000  Views
    What Is The Approximate Salary A Fresher Can Expect In The Indian Market Of Salesforce?

    What Is The Approximate Salary A Fresher Can Expect In The Indian Market Of Salesforce?

    Video in Salesforce Training

    Wondering what is the approximate salary a fresher can expect in the Indian market of Salesforce? Join this useful group for Salesforce job & career…

    Salesforce Training, Salesforce Tutorial, Salesforce Jobs, salesforce, Salesforce Video
    Intelogik Nov 21, 2022
    1,611  Views
    How Link Cartridge Development Can Your Business Storefront | Salesforce Link Cartridge

    How Link Cartridge Development Can Your Business Storefront | Salesforce Link Cartridge

    Video in Salesforce Training

    LINK Cartridge is a container for packaging and deploying program code and data, it’s structured in folders and subfolders for maximum efficiency.

    Salesforce Training, salesforce, Salesforce Video, Salesforce Learning, Link Cartridge Development
    Cyntexa May 12, 2022
    1,680  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®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.