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

    Industry Best Practices to Implement Salesforce Marketing Cloud

    Blog in Salesforce Implementation

    The Salesforce Marketing Cloud is a sophisticated technology developed by Salesforce that automates the marketing of a business across a variety of channels, including but…

    AppExchange, B2B Companies, B2B or B2C, Business Consulting, Business Values
    Cymetrix Mar 23, 2023
    2,239  Views

    Revealing the Hidden Costs of Salesforce Implementation

    Blog in Salesforce

    Could your Salesforce implementation be costing your company more than anticipated? Throughout my experience as a Salesforce consultant, I've had the opportunity to assist clients with…

    Automated Marketing, Business Efficiency, Campaign Analytics, Conversion Rates, Customer Behavior
    Codleo Jul 18, 2024
    665  Views

    How Integrated CRM Payment Solution can Help Nonprofits | Salesforce Solutions

    Blog in Salesforce integration

    If your fundraising team is spending hours monthly to manually import and export data from the increasing payment providers, then they are definitely doing it…

    Automatic Payment, cryptocurrency, Data Management, Data Transfer, Digital Donor Experience
    360 Degree May 11, 2022
    2,182  Views

    Popular Salesforce Videos

    Prepopulate Field values in Salesforce Lightning Experience Using defaultFieldValues

    Prepopulate Field values in Salesforce Lightning Experience Using defaultFieldValues

    Video in Lightning

    Prepopulate Field values in Lightning Experience Using defaultFieldValues - Spring 20 This video demonstrates the following items: Set Record Type Id Using defaultFieldValues Enforce User…

    Salesforce Training, Salesforce Tutorial, Salesforce Lightning, salesforce, Field Values
    Abhishek Jun 2, 2021
    1,855  Views
    Is Generative AI Is The New Future Of Salesforce?

    Is Generative AI Is The New Future Of Salesforce?

    Video in AI and ML, Salesforce Einstein

    Every industry, whether IT, Finance, or health, is moving towards AI? There has been a lot of talk about Generative AI and how it can…

    salesforce, Artificial Intelligence, Salesforce Community, Salesforce Webinar, Salesforce Video
    Cyntexa Aug 30, 2023
    1,066  Views
    The New Salesforce Nonprofit Cloud: How To Upgrade

    The New Salesforce Nonprofit Cloud: How To Upgrade

    Video in Salesforce Products

    The new Salesforce Nonprofit Cloud is an innovative platform tailored specifically to enhance the operations and effectiveness of nonprofit organizations. This advanced solution provides a…

    salesforce, Salesforce For Nonprofits, Nonprofit Success Pack, Salesforce Nonprofit Cloud, Nonprofits
    DB Jun 20, 2024
    715  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.