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

    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
    1,826  Views
    Report Formats in Salesforce

    Types of Report Formats in Salesforce - All You Need to Know

    Blog in Salesforce, Salesforce Products

    What are the Report Formats in Salesforce? A Salesforce report is a list of information produced dependent on predefined standards. They can be displayed in…

    Arrangements, Bucketing Field, Bundle Records, Business, Charts
    Shweta Choudhary Aug 26, 2021
    5,633  Views
    Salesforce Development

    9 Salesforce Development Best Practices

    Blog in Salesforce

    Learning to code might be dreadful for a few of us, but all of us would like to tweak something the way we wish. Salesforce…

    App Building Process, app development, App Development Tools, AppExchange, Application
    Cloudideas May 28, 2021
    2,610  Views

    Popular Salesforce Videos

    Marketing Cloud Connect: View Full Resolution Emails in Sales or Service Cloud

    Marketing Cloud Connect: View Full Resolution Emails in Sales or Service Cloud

    Video in Salesforce Implementation

    Thumbnails don't always cut it. Sometimes you need the full resolution Marketing Cloud email in Sales or Service Cloud to see what was sent to…

    Salesforce Training, Salesforce Tutorial, Salesforce Visualforce, Salesforce Rest API, Apex
    DB Mar 3, 2021
    2,216  Views
    What Is Salesforce Industries (Vlocity)?

    What Is Salesforce Industries (Vlocity)?

    Video in Salesforce Stories

    Vlocity (Salesforce Industries) offers pre-built solutions on the Salesforce platform that solve the needs of particular industries that require CRMs to be heavily customized beyond…

    Salesforce Training, Salesforce Tutorial, salesforce, CRM, salesforce platform
    Cyntexa Sep 5, 2025
    259  Views
    Batch Apex In Salesforce | Asynchronous Apex

    Batch Apex In Salesforce | Asynchronous Apex

    Video in Salesforce Apex, Salesforce Training

    Asynchronous Apex 1. Batch Apex 2. How to run Batch Apex class 3. Monitor Batch Apex class 4. Examples 5. Points To Remember Upcoming Video…

    Salesforce Tutorial, Apex Class, salesforce, Salesforce Video, Salesforce Learning
    kanika Aug 3, 2021
    6,050  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.