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 › 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, 8 months 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

    Popular Salesforce Blogs

    Integrate Your Vanilla-Community With Salesforce to Deliver Seamless, Efficient Support

    Blog in Salesforce integration

    According to a survey conducted by Gartner, 62% of millennials and 75% of GenZ customers prefer self-service instead of seeking assistance from support reps. As a result, online…

    Case Management, Community with CRM, Community-CRM Integration Needs, Connector, Consumers
    Amisha Makkar Nov 21, 2022
    2,010  Views
    Big Objects in Salesforce

    All About Big Objects in Salesforce

    Blog in Others, Salesforce

    In Salesforce, We already know about Standard objects, Custom objects, and External Object. These objects assist you to handle and operate data. But if we…

    APIs, Auditing and Tracking, Big Object, Big Object Information, Client Data
    Shweta Oct 12, 2020
    5,911  Views
    Dashboards in Salesforce

    Dashboards in Salesforce - A Brief Guide

    Blog in Salesforce

    Dashboards in Salesforce are graphical representations of reports. Visualize data from reports as components. These components provide a summary of your organization's key analytics and…

    Bar Chart, Chart, Components, Control Panel, Dashboard Component
    Romil Jun 24, 2022
    5,267  Views

    Popular Salesforce Videos

    How to Create Contact in Salesforce | Salesforce Contacts | Salesforce Tutorial

    How to Create Contact in Salesforce | Salesforce Contacts | Salesforce Tutorial

    Video in Salesforce Training

    Contact in Salesforce represents the individual people associated with the business accounts in your organization or Contact records are used for individuals to store personal…

    Salesforce Training, Salesforce Tutorial, Salesforce Video, Contact in Salesforce, Salesforce Account
    Pooja Mar 8, 2022
    2,080  Views
    Marc Benioff talks Salesforce - AT&T deal, office health safety and online media regulation

    Marc Benioff talks Salesforce - AT&T deal, office health safety and online media regulation

    Video in Salesforce Stories

    Salesforce’s Customer 360 will enable AT&T to deliver highly-tailored customer experiences seamlessly across retail, marketing, online, business, and more. AT&T will utilize Salesforce’s entire portfolio…

    salesforce, Salesforce Einstein, Salesforce Video, Sales Cloud, Tableau
    Pooja May 29, 2020
    2,275  Views
    Types of Generative AI Models | How Does Generative AI Work?

    Types of Generative AI Models | How Does Generative AI Work?

    Video in Others

    Have you ever wondered how AI can be so creative? How do they generate art, music, and even text all on their own? Look no…

    salesforce, Salesforce Community, Salesforce Webinar, Webinar, Live Webinar
    Cyntexa Sep 5, 2025
    296  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.