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 › How to Create a Batch class which append Account's name after each related contact in Salesforce?

    Tagged: Account Name, Batch Class, Contacts, Multiple Accounts, Parent Account, Related Contact, Salesforce Junction Object

    • Salesforce® Discussions

      How to Create a Batch class which append Account's name after each related contact in Salesforce?

      Posted by Prachi on December 9, 2019 at 6:04 PM

      How to Create a Batch class which append Account's name after each related contact?

      Deepak replied 6 years, 3 months ago 2 Members · 1 Reply
      • Account Name
      • Batch Class
      • Contacts
      • Multiple Accounts
      • Parent Account
      • Related Contact
      • Salesforce Junction Object
    • 1 Reply
    • Deepak

      Member
      December 10, 2019 at 2:44 PM

      I believe you are trying to associate a single contact to multiple accounts. This functionality was released in Spring 16' and is implemented through a Salesforce Junction object - AccountContactRelation.

      I assume you have already enabled this functionality through the UI and a parent Account is declared for this Contact.

      I have modified your code to associate the contact to all 20 account.

      global class UpdateProjectNameBatch implements Database.Batchable
      <sObject>
      { ID conId = '0037F00000IfCCKQA3'; //Add the contact Id here
      List<AccountContactRelation> ListInsertion = new List<AccountContactRelation>();
      String query = 'Select Id,Name FROM Account WHERE Name = 'SampleAccountOne'';

      global Database.QueryLocator start(Database.BatchableContext bc)
      {
      return Database.getQueryLocator(query);
      }

      global void execute(Database.BatchableContext bc,List<Account> batch){

      for (Account a : batch)
      {
      AccountContactRelation c = new AccountContactRelation();

      c.AccountId = a.id;
      c.contactId = conId;
      ListInsertion.add(c);
      }

      Insert ListInsertion;

      }

      global void finish(Database.BatchableContext bc)
      {
      //DoNothing.
      }
      }

    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

    Top 10 Things to Know About Salesforce

    Blog in Others

    Administrators/Devs/Consultants are a key piece of any business that has a Salesforce execution, they keep things ticking over just as extending Salesforce to incorporate new…

    App Customization, Object Relationship, Process Automation, Salesforce Admin, Salesforce Certification
    Akhila Nov 28, 2019
    13,999  Views

    Insider Tips for an Easy Migration into Salesforce

    Blog in Data Migration, Salesforce

    As the owner of a growing nonprofit enterprise, you need to find the right tools to ensure that your company can quickly adapt to its…

    AppExchange Apps, Applications, Business, Clients, Communications
    Apphienz Aug 4, 2021
    1,772  Views
    Salesforce Editions

    All You Need to Know About Salesforce Editions

    Blog in Salesforce

    Salesforce gives packs of highlights and administrations that are explicit for the diverse business needs. These packs are known as Editions in Salesforce.  Every release…

    Authorization Sets, Business Applications, Business Needs, Business Prerequisite, Case Management
    Pooja Mar 26, 2021
    3,688  Views

    Popular Salesforce Videos

    LWC Interview Questions -1 ( Freshers)

    LWC Interview Questions -1 ( Freshers)

    Video in Salesforce Training

    In this video, Kumar Salesforce provides a list of LWC Interview Questions that may be helpful for those who are just starting out. Watch this…

    Salesforce Lightning, Salesforce Lightning Components, Salesforce Interview Questions, Store Lightning Web Components
    Rahul kapoor Oct 6, 2022
    3,078  Views
    Salesforce Trailhead Bootcamp - Fast Track your Salesforce Certification - $700 OFF LIMITED TIME

    Salesforce Trailhead Bootcamp - Fast Track your Salesforce Certification - $700 OFF LIMITED TIME

    Video in Salesforce Certifications, Salesforce Training

    If want to fast track the path to your Salesforce Administrator Certification then this video is for you! This offer includes your $200 Certification Voucher…

    Salesforce Certification, Salesforce Administrator, salesforce, Salesforce Trailhead, Salesforce Admin
    Bradley May 14, 2020
    7,015  Views
    What Is Loyalty Management in Salesforce?

    What Is Loyalty Management in Salesforce?

    Video in Salesforce Training

    Loyalty Management is a strategy employed by companies to focus on acquiring, engaging, and retaining customers. Have a glance at this extract to discover what…

    Salesforce Training, Salesforce Tutorial, Customer Relationship Management, customer service, Salesforce Learning
    Cyntexa Nov 16, 2022
    1,339  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.