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 › I want to copy the contacts from one account to another not from one user to another. How is it possible to do it in Salesforce?

    Tagged: Account, Contact, Migration, User

    • Salesforce® Discussions

      I want to copy the contacts from one account to another not from one user to another. How is it possible to do it in Salesforce?

      Posted by PRANAV on July 19, 2016 at 3:38 PM

      Hi All,

      I want to copy the contacts from one account to another not from one user to another. How is it possible to do it in salesforce?

      Thanks

      Shubham replied 10 years, 3 months ago 2 Members · 2 Replies
      • Account
      • Contact
      • Migration
      • User
    • 2 Replies
    • Shubham

      Member
      July 20, 2016 at 3:49 PM

      Hi Pranav,

       

      You can do this with the help of apex and VF page. Here is a sample code you can use and customize as per your requirement.

      VF page

      [[code]]czo3NzU6XCImbHQ7YXBleDpwYWdlIGNvbnRyb2xsZXI9XFwmcXVvdDtDb3B5Q29udGFjdHNDb250cm9sbGVyXFwmcXVvdDsgdGFiU3R5bHtbJiomXX1lPVxcJnF1b3Q7QWNjb3VudFxcJnF1b3Q7Jmd0OwogICAgJmx0O2FwZXg6Zm9ybSBpZD1cXCZxdW90O3RoZUZvcm1cXCZxdW90OyZndDsKIHtbJiomXX0gICAgICAgJmx0O2FwZXg6cGFnZU1lc3NhZ2VzLyZndDsKICAgICAgICAmbHQ7YXBleDpwYWdlQmxvY2sgdGl0bGU9XFwmcXVvdDtDb3tbJiomXX1weSBDb250YWN0c1xcJnF1b3Q7Jmd0OwogICAgICAgICAgICBBY2NvdW50IDEgSUQgJmx0O2FwZXg6aW5wdXRUZXh0IHJlcXVpcmVkPXtbJiomXX1cXCZxdW90O3RydWVcXCZxdW90OyB2YWx1ZT1cXCZxdW90O3shYWNjMUlkfVxcJnF1b3Q7LyZndDsKICAgICAgICAgICAgQWNjb3VudCAyIHtbJiomXX1JRCAmbHQ7YXBleDppbnB1dFRleHQgcmVxdWlyZWQ9XFwmcXVvdDt0cnVlXFwmcXVvdDsgdmFsdWU9XFwmcXVvdDt7IWFjYzJJZH1cXCZxdXtbJiomXX1vdDsvJmd0OwogICAgICAgIAogICAgICAgICAgICAmbHQ7YXBleDpwYWdlQmxvY2tCdXR0b25zJmd0OwogICAgICAgICAgICAgICAge1smKiZdfSZsdDthcGV4OmNvbW1hbmRCdXR0b24gYWN0aW9uPVxcJnF1b3Q7eyFjb3B5Q29udGFjdHN9XFwmcXVvdDsgdmFsdWU9XFwmcXVvdDtDb3B7WyYqJl19eSBDb250YWN0c1xcJnF1b3Q7IHJlUmVuZGVyPVxcJnF1b3Q7dGhlRm9ybVxcJnF1b3Q7LyZndDsKICAgICAgICAgICAgJmx0Oy9hcGV4OntbJiomXX1wYWdlQmxvY2tCdXR0b25zJmd0OwogICAgICAgICZsdDsvYXBleDpwYWdlQmxvY2smZ3Q7ICAgIAogICAgJmx0Oy9hcGV4OmZvcm0me1smKiZdfWd0OwombHQ7L2FwZXg6cGFnZSZndDtcIjt7WyYqJl19[[/code]]

      Controller

      [[code]]czo5NjU6XCJwdWJsaWMgY2xhc3MgQ29weUNvbnRhY3RzQ29udHJvbGxlciB7CiAgICBwdWJsaWMgU3RyaW5nIGFjYzFJZHtnZXQ7c2V7WyYqJl19dDt9CiAgICBwdWJsaWMgU3RyaW5nIGFjYzJJZHtnZXQ7c2V0O30KICAgIHB1YmxpYyBMaXN0Jmx0O0NvbnRhY3QmZ3Q7IGNvbkxpc3tbJiomXX10OwogICAgCiAgICBwdWJsaWMgQ29weUNvbnRhY3RzQ29udHJvbGxlcigpe30KICAgIAogICAgcHVibGljIHZvaWQgY29weUNvbnRhe1smKiZdfWN0cygpewogICAgICAgIGNvbkxpc3QgPSBuZXcgTGlzdCZsdDtDb250YWN0Jmd0OygpOwogICAgICAgIHRyeXsKICAgICAgICAgICB7WyYqJl19IGZvcihDb250YWN0IGNvbiA6W3NlbGVjdCBsYXN0bmFtZSxlbWFpbCxwaG9uZSBmcm9tIGNvbnRhY3Qgd2hlcmUgQWNjb3VudElkIHtbJiomXX09OmFjYzFJZF0pewogICAgICAgICAgICAgICAgQ29udGFjdCBjb250b0FkZCA9IG5ldyBDb250YWN0KAogICAgICAgICAgICAgICAge1smKiZdfQlMYXN0TmFtZSA9IGNvbi5MYXN0TmFtZSwKICAgICAgICAgICAgICAgICAgICBBY2NvdW50SWQgPSBhY2MySWQsCiAgICAgICAgICB7WyYqJl19ICAgICAgICAgIEVtYWlsID0gY29uLkVtYWlsLAogICAgICAgICAgICAgICAgICAgIFBob25lID0gY29uLnBob25lCiAgICAgICAgIHtbJiomXX0gICAgICAgKTsKICAgICAgICAgICAgICAgIGNvbkxpc3QuYWRkKGNvbnRvQWRkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpe1smKiZdfW5zZXJ0IGNvbkxpc3Q7CiAgICAgICAgICAgIEFwZXhQYWdlcy5hZGRtZXNzYWdlKG5ldyBBcGV4UGFnZXMubWVzc2FnZShBcGV4UGF7WyYqJl19Z2VzLnNldmVyaXR5LkNPTkZJUk0sXFwmIzAzOTtDb250YWN0cyBDb3BpZWQgU3VjY2Vzc2Z1bGx5XFwmIzAzOTspKTsKICAgICAgICB9e1smKiZdfWNhdGNoKEV4Y2VwdGlvbiBlKXsKICAgICAgICAgICAgIEFwZXhQYWdlcy5hZGRtZXNzYWdlKG5ldyBBcGV4UGFnZXMubWVzc2FnZSh7WyYqJl19QXBleFBhZ2VzLnNldmVyaXR5LkVycm9yLGUuZ2V0TWVzc2FnZSgpKSk7CiAgICAgICAgfQogICAgfQp9XCI7e1smKiZdfQ==[[/code]]
      • This reply was modified 10 years, 3 months ago by  Shubham.
      • This reply was modified 10 years, 3 months ago by  Shubham.
    • [adinserter block='9']
    • Shubham

      Member
      July 21, 2016 at 7:26 AM

      Hi Pranav,

      You can do this with the help of apex and VF page. Here is a sample code you can use and customize as per your requirement.

      VF page

      <apex:page controller="CopyContactsController" tabStyle="Account">
      <apex:form id="theForm">
      <apex:pageMessages />
      <apex:pageBlock title="Copy Contacts">
      Copy Contacts from Account ID <apex:inputText required="true" value="{!acc1Id}"/>
      Copy Contacts to Account ID <apex:inputText required="true" value="{!acc2Id}"/>

      <apex:pageBlockButtons >
      <apex:commandButton action="{!copyContacts}" value="Copy Contacts" reRender="theForm"/>
      </apex:pageBlockButtons>
      </apex:pageBlock>
      </apex:form>
      </apex:page>

      Controller

      public class CopyContactsController {
      public String acc1Id{get;set;}
      public String acc2Id{get;set;}
      public List conList;

      public CopyContactsController(){}

      public void copyContacts(){
      conList = new List();
      try{
      for(Contact con :[select lastname,email,phone from contact where AccountId =:acc1Id]){
      Contact contoAdd = new Contact(
      LastName = con.LastName,
      AccountId = acc2Id,
      Email = con.Email,
      Phone = con.phone
      );
      conList.add(contoAdd);
      }
      insert conList;
      ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Contacts Copied Successfully'));
      }catch(Exception e){
      ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,e.getMessage()));
      }
      }
      }

      • This reply was modified 10 years, 3 months ago by  Shubham.
      • This reply was modified 10 years, 3 months ago by  Shubham.

    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

    Record Level Security

    Record Level Security in Salesforce

    Blog in Salesforce Security

    After you've finished configuring access rights at the object and field levels, you can go on to configuring access permissions for individual records. You can…

    Automatic Exceptions, Configuring Access, Configuring Access Permissions, Data Access, Field-level Access
    Shivam Apr 8, 2022
    3,919  Views

    A Deep Dive into AbstraLinx's Integration with ChatGPT's Generative AI

    Blog in Salesforce Tools

    Hello Salesforce enthusiasts! Today, we are discussing the release of the new update for AbstraLinx by Softbuilder. This new release brings a whole new dimension…

    API requests, Auto-Generated Content, Auto-Generated Descriptions, ChatGPT Integration, Data Glossaries
    John Oct 18, 2023
    1,801  Views

    Welkin's Customizable Path Brings your Salesforce Sales Path to a Completely New Level

    Blog in AppExchange, Sales

    We're extremely glad to introduce to you our new AppExchange product - Welkin's Customizable Path. Would you like to give your users better visibility of…

    AppExchange, Configuration Options, Configure, Configuring Salesforce Record Type, Custom Objects
    The Welkin Suite Oct 28, 2021
    5,320  Views

    Popular Salesforce Videos

    What All Industries Are Covered By Salesforce Industries?

    What All Industries Are Covered By Salesforce Industries?

    Video in Salesforce Stories, Salesforce Cloud Platform

    Salesforce Industries offers a collection of 12 industry clouds that are suited to the best practices for these sectors. Salesforce Industries aids businesses in navigating…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Webinar, Salesforce clouds
    Cyntexa Sep 20, 2022
    1,595  Views
    How to Reference Custom Metadata Types to Optimize Salesforce Account Records Using Salesforce Flow

    How to Reference Custom Metadata Types to Optimize Salesforce Account Records Using Salesforce Flow

    Video in Salesforce Development

    Watch this video to learn how to reference custom metadata types to optimize Salesforce Account Records Using Salesforce Flow Salesforce Account Region Allocation using custom…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Flow, Salesforce Video
    Prafull Jun 8, 2021
    1,845  Views
    How Salesforce Supports Military Families

    How Salesforce Supports Military Families

    Video in Salesforce Stories

    Join Rachel Dishman, Lead Solution Engineer at Salesforce, as she discusses the ways that Salesforce supports military families. By tuning in, you'll hear more about…

    Salesforce Training, Salesforce Tutorial, Salesforce Jobs, salesforce, Salesforce Ecosystem
    Prafull Nov 12, 2021
    2,132  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.