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

    Federated Authentication Using SAML to Log in to Salesforce Org

    Blog in Others

    Federated Authentication is one of the SSO(Single Sign On) Methods that uses SAML(Security Assertion Markup Language) assertion sent to the Salesforce endpoint and if everything…

    Axiom, Identity Provider, Salesforce Encryption, Salesforce Security, Security Assertion
    Naman Apr 20, 2016
    15,839  Views

    Stripe Integration with Salesforce

    Blog in Salesforce integration

    So firstly what is a stripe? Stripe is the most commonly used payment gateway. Stripe is widely used by e-commerce, subscription-based services, and by many…

    API key, Challenges, Contact, Custom Metadata, Customer
    Kizzy Consulting Jun 6, 2023
    2,286  Views

    Review of Top 5 Free Salesforce Data Cleansing Tools [+ Salesforce Data Cleansing Best Practices]

    Blog in Salesforce Data integration

    Keeping your CRM data clean is not only a technical activity. It also involves a creative mind, time, and deep knowledge of the business nuances…

    API, AppExchange, Ascendix Search App for Salesforce, Automated Data Cleansing, Bad data
    Angie Sep 21, 2021
    3,391  Views

    Popular Salesforce Videos

    AMPscript FOR LOOP - Salesforce Marketing Cloud Functions in 5 minutes

    AMPscript FOR LOOP - Salesforce Marketing Cloud Functions in 5 minutes

    Video in Marketing, Salesforce Cloud Platform

    Salesforce Marketing Cloud functions in 5 minutes! In this video Cameron Robert shows how FOR LOOPs work in Salesforce Marketing Cloud using some helpful visuals…

    Salesforce Training, Salesforce Tutorial, Salesforce Marketing Cloud, Trailhead, Salesforce Trailhead
    Cameron Sep 21, 2021
    5,657  Views
    How to Get Experience Without the Job? | Salesforce Learning

    How to Get Experience Without the Job? | Salesforce Learning

    Video in Salesforce Training

    Want to get experience without the job? Watch the full episode here: https://youtu.be/oG8sHOW8GI4 Shrey is a Chief Executive Officer at Cyntexa, a SILVER Salesforce Consulting…

    Salesforce Training, salesforce, Salesforce Hulk, Salesforce Video, Salesforce Learning Courses
    S2 Nov 18, 2021
    2,540  Views
    Introduction to Lightning Web Components (LWC)

    Introduction to Lightning Web Components (LWC)

    Video in Others

    Why Lightning Web Component (LWC) Part 1 - Vanilla HTML5 Web Components Benefits of Web Component Pillars of Web Component Demo of Custom Element and…

    Salesforce Lightning Components, Easy Way To Learn Salesforce, How To Learn Salesforce Lightning, Best Salesforce Tutorials, Salesforce Lightning Tutorial
    Apex Feb 11, 2019
    5,062  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.