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

    application solution

    Popular Salesforce Blogs

    How Salesforce’s Acquisition of Slack Will Reshape the Market

    Blog in Salesforce

    Salesforce acquiring Slack has been the talk of the town for a while. The deal finally got a green light on December 01, 2020, when…

    App Ecosystem, Applications, Apps and Workflows, Automate Workflows, Box
    Rohit Thakur Jul 27, 2021
    2,362  Views
    Calling from Salesforce

    Calling from Salesforce: Use RingCentral

    Blog in Lightning

    Hello Everyone, Salesforce is nowadays a huge platform for all the developers, administrators, and users as well. So in this tech world, everyone needs a…

    Calling from Salesforce, Cloud Computing, Cloud Computing Salesforce, productivity, Salesforce AppExchange
    PRANAV Mar 26, 2018
    3,673  Views
    Health Cloud Console

    Health Cloud Console Unit in Salesforce - Get Started

    Blog in Salesforce Cloud Platform

    In this blog, we will discuss about Health Cloud, its specific terminology, and its architecture. Let’s move to Salesforce Health Cloud Core Capabilities which are:…

    Architecture, Business Accounts, Care Plans, Chatter Component, Dashboard
    bhawana Nov 23, 2022
    2,497  Views

    Popular Salesforce Videos

    Classes and Objects in Salesforce | Tutorial Video

    Classes and Objects in Salesforce | Tutorial Video

    Video in Salesforce Apex

    The concept of OOPs is really important for any developer who is working with Salesforce or JavaScript, Java, or any other programming language. I have…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Career, Javascript
    SFDC Sep 14, 2022
    1,963  Views
    Salesforce Billing - Digital Wallets and Alternative Payment Methods

    Salesforce Billing - Digital Wallets and Alternative Payment Methods

    Video in Others, Salesforce Stories

    THE GOAL:  In this video, you will learn how to use Alternative Payment Methods and Digital Wallets with Salesforce Billing. BEFORE YOU BEGIN, KNOW THE…

    salesforce, Salesforce Video, Salesforce Billing, Digital Wallets, Alternative Payment Methods
    Jogender Jul 1, 2020
    3,529  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
    845  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

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