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

    Salesforce Training And Certifications

    How Salesforce Training And Certifications Help with Better Career Opportunities for IT Professionals

    Blog in Salesforce Training

    About: If you're looking for it, then BismilSoft gives you the fine Salesforce education direction in Noida with stay task and certification. The Salesforce education…

    Best Practices, Builds Custom Packages, Businesses, Career Opportunities, certification
    shanu Sep 3, 2021
    2,926  Views
    Salesforce Security Model

    Salesforce Security Model - An Overview

    Blog in Salesforce Security

    What is Salesforce Data Security? Presently Salesforce offers a thorough and flexible data security model for tying down data at totally various levels to give…

    Apps, Associate Admin, Business Profile, Campaigns Object, Certifiable Business Issues
    Ratnesh Feb 11, 2021
    5,017  Views
    Salesforce Slack Acquisition

    Salesforce Slack Acquisition – 5 Reasons Why This Merger is the Best Thing Since Sliced Bread!

    Blog in Salesforce integration

    Salesforce is bringing in a huge wave of features and services for its users this year. Before the end of 2020, Salesforce signed a $27.7 billion megadeal to…

    Business Apps, Cases, Channel of Communication, Channel-based Messaging Platform, Code Blocks
    LevelShift (formerly DemandBlue) Jan 20, 2021
    3,175  Views

    Popular Salesforce Videos

    Creating a To-do List with Custom Events | Salesforce Developer Quick Takes

    Creating a To-do List with Custom Events | Salesforce Developer Quick Takes

    Video in Others, Events, Salesforce Training

    Creating a ToDo list will show us how we can take data from one component and pass it to another. In our ToDo list component,…

    Salesforce Training, Salesforce Tutorial, Salesforce Developer, Salesforce Video, Salesforce Learning
    Jogender Mar 3, 2021
    1,586  Views
    What Is The Approximate Salary A Fresher Can Expect In The Indian Market Of Salesforce?

    What Is The Approximate Salary A Fresher Can Expect In The Indian Market Of Salesforce?

    Video in Salesforce Training

    Wondering what is the approximate salary a fresher can expect in the Indian market of Salesforce? Join this useful group for Salesforce job & career…

    Salesforce Training, Salesforce Tutorial, Salesforce Jobs, salesforce, Salesforce Video
    Intelogik Nov 21, 2022
    1,413  Views
    Salesforce Lightning Tutorial - How to Delete Records from Server

    Salesforce Lightning Tutorial - How to Delete Records from Server

    Video in Lightning

    In this particular video you'll learn how to delete records from custom Salesforce Lightning Component using Apex Controller Method.

    Salesforce Records, Easy Way To Learn Salesforce, How To Learn Salesforce Lightning, How to Salesforce Lightning Component, Building Lightning Components in Salesforce
    Abhay Dec 19, 2018
    2,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®.

    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.