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

    Popular Salesforce Blogs

    Salesforce Implementation Costs: Factors to Consider and Average Expenses

    Blog in Salesforce Implementation

    According to the Total Cost of Ownership of Salesforce study, there are a few main factors regarding CRM adoption decisions.  The financial sting of ongoing costs…

    AppExchange, Business Needs, Case Study, CRM Adoption, Customization
    Twistellar Apr 4, 2024
    2,386  Views

    How Large Enterprises Can Create Tailored Digital Experiences for Their Stakeholders?

    Blog in Salesforce Cloud Platform

    Introduction In today's digital world, businesses need to move ahead of one-size-fits-all approaches to meet the diverse requirements of their customers, partners, and employees. Personalized…

    Customer Experience, Digital Experience, Salesforce Experience Cloud
    Concretio Aug 1, 2025
    373  Views
    Salesforce Marketing Cloud Products

    Salesforce Marketing Cloud Products

    Blog in Salesforce Cloud Platform

    Salesforce Marketing Cloud Products Marketing Cloud is a family of seven primary products which are further categorized into three different buckets. Every product and various…

    Data Studio, Email Studio, Journey Builder, Marketing Cloud, Marketing Cloud Advertising and Data Products
    Archit Jan 31, 2018
    16,583  Views

    Popular Salesforce Videos

    How Salesforce Industries can be Used on Top of Salesforce?

    How Salesforce Industries can be Used on Top of Salesforce?

    Video in Salesforce Training

    Salesforce Industries offers pre-built solutions on the Salesforce platform that solve the needs of particular industries. Vlocity takes these common requirements and packages them into…

    Salesforce Training, Salesforce Tutorial, Salesforce Development, salesforce, Salesforce Admin
    Cyntexa Nov 18, 2022
    1,567  Views
    Salesforce for Marketing

    Salesforce for Marketing

    Video in Marketing

    Learn how to bring marketing and engagement together. Salesforce Marketing Cloud helps you connect marketing, sales, service, and more on a single platform. Marketers get…

    Salesforce Marketing Cloud, Salesforce Video, sales, Marketing, Service
    Manpreet Jun 12, 2020
    1,579  Views
    How to Deliver Great Customer Service With a Small Team [Salesforce Webinar]

    How to Deliver Great Customer Service With a Small Team [Salesforce Webinar]

    Video in Salesforce Training

    Overwhelmed by a backlog of customer service requests? And worried your team is too small to handle all the requests? Then, this video is for…

    Salesforce Online Training, Customer Success, Best Salesforce Tutorials, Automate Business Processes, Sales Productivity
    Jogender Mar 27, 2018
    2,120  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.