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 › Fetch account details using "AccountContactRelation" junction object in Salesforce

    Tagged: Account Detail, AccountContactRelation, Junction Object, Salesforce Objects, Salesforce Org

    • Salesforce® Discussions

      Fetch account details using "AccountContactRelation" junction object in Salesforce

      Posted by Martina on November 20, 2017 at 7:52 PM

      Hi,

      I am stuck with a problem here.

      I have enabled multiple Accounts to Contact in my Salesforce org. This creates a junction object called AccountContactRelation.

      I need to write a query which would fetch the account details like Account id, name, record type of the Accounts linked to a Contact.

      Condition is, only those account details should be fetched where the contact has more than one account linked to it.

      Can someone please help. It is urgent

      Thanks!

      Ajay Prakash replied 8 years ago 2 Members · 1 Reply
      • Account Detail
      • AccountContactRelation
      • Junction Object
      • Salesforce Objects
      • Salesforce Org
    • 1 Reply
    • Ajay Prakash

      Member
      January 4, 2018 at 5:37 AM

      Hi Martina,

      It will be a two-step process. First, you need to fetch all contact ids which has more than one contact.In the second step, you can retrieve Account information.

      set<Id> setOfContactIds = new set<id>();
      for(Contact conObj : [select id, (select id from AccountContactRelations where isDirect = false) from contact]){
      if(conObj.AccountContactRelations.size()>0){
      setOfContactIds.add(conObj.id);
      }
      }
      system.debug('::'+[select id, Account.name from AccountContactRelation where ContactId IN:setOfContactIds]);

    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

    The endless configuration possibilities with Salesforce data — for phones and tablets

    Blog in Salesforce customization

    So, you decided to go mobile with Salesforce for your sales, field service and further teams that work outside the office doors. Now, you get two options to…

    AppExchange Apps, Business Mobility, Charts, Configuration, Create Button
    Barbora Jan 9, 2019
    4,101  Views
    Create User in Salesforce

    How to Create User in Salesforce | The Developer Guide

    Blog in Salesforce Training

    Introduction: A user is a person who has credentials to login into Salesforce and is able to use the assigned application in Salesforce. The user…

    Application in Salesforce, Chatter User Profiles, Create Profile, Create User in Salesforce, Creating a User
    Rajat Shende Oct 8, 2021
    7,424  Views

    Why Choosing the Right Salesforce Development Company Defines Your CRM Success

    Blog in Salesforce

    In today’s digital ecosystem, customer experience is no longer optional; it is the core driver of business growth. Whether you’re a startup scaling operations or…

    Salesforce Development Company, Salesforce Development Services
    Dean Dec 3, 2025
    2,134  Views

    Popular Salesforce Videos

    Leads & Opportunities for Lightning Experience - Create and Convert Leads

    Leads & Opportunities for Lightning Experience - Create and Convert Leads

    Video in Lightning

    Learning Objectives After completing this unit, you’ll be able to: Update a record’s stage or status using Path. Update records in the Kanban view. Use…

    Salesforce Training, Salesforce Lightning, salesforce, Trailhead, Salesforce Trailhead
    Vivek Apr 20, 2020
    2,450  Views
    What Is Salesforce and Why Is It So Good?

    What Is Salesforce and Why Is It So Good?

    Video in Salesforce Stories

    Salesforce is by far the most popular CRM tool for sales, support, and marketing teams worldwide. But what exactly is a CRM and why do…

    Salesforce Development, salesforce, salesforce knowledge, CRM, Salesforce Developers
    Pooja Aug 7, 2020
    1,957  Views
    Work.com – Release Readiness LIVE, Summer '20 | Salesforce

    Work.com – Release Readiness LIVE, Summer '20 | Salesforce

    Video in Salesforce Stories, Salesforce Products

    Work.com is an online set of applications, resources, and content designed to help the entire workplace get back to business after the Covid-19 crisis. This…

    Workdotcom, Summer 20, COVID-19, Summer '20 Release, Salesforce Release
    Pooja Aug 14, 2020
    1,390  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.