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

    application solution

    Popular Salesforce Blogs

    LWC vs React: An In-Depth Comparison of Component-Based UI Frameworks

    Blog in Others

    In the ever-evolving realm of web development, where innovation constantly pushes the boundaries of what can be achieved, two front-end frameworks have emerged as leaders…

    Callbacks, Component Communication, Component Lifecycle, Component-based Architecture, connectedCallback
    Mousin Oct 16, 2023
    2,337  Views

    AppExchange vs Custom Development: Considering Your Options in Salesforce

    Blog in Salesforce

    Salesforce AppExchange is a marketplace of pre-built applications and components that you can install into your Salesforce organization. Custom development is the process of building…

    AppExchange, Custom Development
    Apphienz Dec 29, 2022
    1,777  Views

    The Impact of Salesforce On Your Customer Service Performance

    Blog in Salesforce

    Technology and innovation are changing the way businesses interact with customers. One such innovation is the use of customer relationship management (CRM) tools to help…

    Application of Salesforce, Attract New Prospects, Better Engagements, Better Relationships, Better Solutions
    Apphienz Mar 17, 2021
    2,060  Views

    Popular Salesforce Videos

    How To Create Workflow Rules In Salesforce | Salesforce Workflow Rules

    How To Create Workflow Rules In Salesforce | Salesforce Workflow Rules

    Video in Salesforce Training

    This video walks through the steps to create a Workflow Rule within the Process Automation section of Lightning Settings in Salesforce. Get answers to the…

    Salesforce Training, Salesforce Tutorial, Salesforce Lightning, Process Automation, salesforce
    Algoworks Sep 16, 2021
    1,456  Views
    How to Configure and Customize Salesforce Lightning

    How to Configure and Customize Salesforce Lightning

    Video in Lightning, Salesforce Training

    A Salesforce expert will guide you through all of the configuration, customization, and personalization options available so you can get the most out of Lightning…

    Salesforce Training, Salesforce Lightning, salesforce, Sales Productivity, Salesforce Lightning App
    Prafull Jul 20, 2021
    2,241  Views
    Salesforce Summer ’22 Release | Flow Enhancement of Summer 22 Release with Example

    Salesforce Summer ’22 Release | Flow Enhancement of Summer 22 Release with Example

    Video in Salesforce Stories

    Exceed your business goals with the Summer ’22 release by seamlessly integrating your data, finding meaningful insights, and building lifelong customer relationships. How to Use…

    Salesforce Training, salesforce, Salesforce Video, Salesforce Learning, Release Notes
    Rupal Kakkar May 13, 2022
    1,664  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.