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, 7 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

    Top7 Benefits of Using Salesforce CDP in 2023

    Blog in Salesforce Products

    Summer ’21 was the relaunch of Customer 360 Audience, which brought Salesforce CDP to the forefront. In previous articles, we explained what a CDP consists…

    AppExchange, Applications, AWS Cloud, Business Needs, CDP
    SkyPlanner Dec 19, 2022
    1,496  Views

    All You Need to Know About Test Class in Salesforce

    Blog in Others

    Test classes in Salesforce are a vital component of the Salesforce development process. These classes are used to test the functionality and effectiveness of Apex…

    Apex Test Class, Apex Test Runner, Apex Trigger, ApplyDiscount, assertEquals
    Rahul May 31, 2023
    1,520  Views

    How to Easily Choose the Top Salesforce Consulting Partner in the UK?

    Blog in Salesforce Consultant

    Choosing the right Salesforce consulting partner can be a game-changer for your business, especially in a competitive market like the UK. With numerous consulting firms…

    Best Salesforce Consulting Firm, best Salesforce consulting partner, Best Salesforce Consulting Services, Best Salesforce Partner UK, Certified Salesforce Consultants
    Codleo Sep 25, 2024
    921  Views

    Popular Salesforce Videos

    Integrating Salesforce Data Cloud With Other Clouds

    Integrating Salesforce Data Cloud With Other Clouds

    Video in Data

    In this extract, our speakers discussed the integration capabilities of the Salesforce Data Cloud with other clouds. Salesforce data cloud integrates with a wide range…

    Salesforce Tutorial, salesforce, Salesforce Video, Sales Cloud, Marketing Cloud
    Cyntexa Sep 5, 2025
    220  Views
    Salesforce Chatter Tutorial | Chatter Overview And Demo | Chatter In Salesforce

    Salesforce Chatter Tutorial | Chatter Overview And Demo | Chatter In Salesforce

    Video in Salesforce Apps

    This Salesforce Chatter Tutorial will give an overview of Chatter which includes enabling chatter, configuring chatter groups and creating customer groups. Salesforce Chatter will be…

    Salesforce Training, Salesforce Chatter, Salesforce Online Training, Salesforce Developer, Salesforce Demo
    Simplilearn Apr 23, 2019
    4,536  Views
    What All Industries Are Covered By Salesforce Industries?

    What All Industries Are Covered By Salesforce Industries?

    Video in Salesforce Stories, Salesforce Cloud Platform

    Salesforce Industries offers a collection of 12 industry clouds that are suited to the best practices for these sectors. Salesforce Industries aids businesses in navigating…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Webinar, Salesforce clouds
    Cyntexa Sep 20, 2022
    1,529  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.