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, 2 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, 2 months ago by  Shubham.
      • This reply was modified 10 years, 2 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, 2 months ago by  Shubham.
      • This reply was modified 10 years, 2 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

    Top Salesforce Winter '22 Nonprofit Release Features

    Blog in Salesforce, Salesforce Releases

    Nonprofits have unique requirements, and Salesforce is familiar with them. There's nothing your Nonprofit can't accomplish with its effective resources. With one-of-a-kind Salesforce solutions, they…

    Application Evaluation, Automation Studio, Best-performing Giving Pages, Campaign, Contact Data
    Apphienz Sep 24, 2021
    2,279  Views

    How Using Salesforce Chatter Can Serve a Business

    Blog in Salesforce Implementation, Salesforce Products

    Salesforce Chatter is an enterprise social network used in many companies for team engagement and collaboration. The platform came up as an extension to Salesforce1…

    Boost Innovation, Business, Business Functioning, Business Goal, Chatter
    360 Degree Apr 5, 2022
    2,736  Views
    Named Credentials

    Integration Using Named Credentials | Salesforce Developer Guide

    Blog in Salesforce Training

    The Following are the Benefits of Using Named Credentials: A Named credential specifies the end URL of the callout and its verification parameters required in…

    Authentication Protocol, Authentication Protocols, Callback URL, Callout Description, Connected Apps
    rajesh andani May 4, 2022
    7,321  Views

    Popular Salesforce Videos

    Video calling in Salesforce using WebRTC

    Video calling in Salesforce using WebRTC

    Video in Salesforce Training

    Enhance your contact center offering by integrating WebRTC video calling directly into Salesforce Service Cloud. This video will guide you in understanding how you can…

    Salesforce Service Cloud, salesforce, Salesforce Video, Video calling in Salesforce, Video Calling
    Prafull Jul 15, 2020
    2,786  Views
    The Salesforce Team is Talking About What Working for Salesforce is Like

    The Salesforce Team is Talking About What Working for Salesforce is Like

    Video in Salesforce Stories

    The Salesforce team is talking about what working for Salesforce is like. Watch this video learn about their experience.

    Salesforce Training, Salesforce Tutorial, Salesforce Jobs, salesforce, Salesforce Video
    Vivek Nov 26, 2021
    2,041  Views
    How to Test Your Process Builder | Salesforce

    How to Test Your Process Builder | Salesforce

    Video in Salesforce Training

    In this video, Appopedia provides helpful tips on how to test your process builder in Salesforce. She explains how to create a test user, what…

    Salesforce Training, Salesforce Tutorial, Salesforce Apex, salesforce, Salesforce Trailhead
    Rahul kapoor Aug 18, 2022
    2,249  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.