• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

 MIGRATION

Salesforce Migration

Force.com Migration Tools:

The Force.com Migration Tool is a Java/Ant-based command-line utility for moving metadata between a local directory and a Salesforce organization. Migration tool is useful for migrating large scale or repetitive changes between environments.

Migration tools scenarions

  • Development projects where we need to populate a test environment with large amounts of setup changes—making changes with an automated script is far faster than entering them by hand.
  • Deployments where we need to change the contents of files between organizations.
  • Multi-stage release processes—a typical development process requires iterative building, testing, and staging before releasing to a production environment.We can retrieve metadata from sourceenvironment, make changes, and deploy our changes to destination environment. If we need to repeat this process, it is as simple as calling the same deployment target again.

Prerequisites

Prerequisites for using Force.com Migration Tool:

Before using Force.com Migration Tool, Java and Ant must be installed correctly.

Installations

Installing Java:

In a Web browser, navigate to http://java.sun.com/javase/downloads/index.jsp and install the latest version of the Java JDK.

Verify Java Installation:

To see if we have Java installed:

In command prompt, type java -version and press Enter.

The output should look something like the following:

java version “1.5.0_01”
Java(TM) SE Runtime Environment (build 1.5.0_01-b06)
Java HotSpot(TM) Client VM (build 1.5.0_01-b06, mixed mode)

Ant Installation:

 Download Apache Ant  .http://ant.apache.org/bindownload.cgi.

This directory will be known as ANT_HOME.  Add the bin directory to your path. (Only the bin and lib directories are required to run Ant.)

If we are using a Windows operation system, create an ANT_HOME environment variable and set the value to where we have installed Ant. Also create a JAVA_HOME environment variable and set the value to the location of your JDK.

Verify Ant Installation

  • %In the command prompt, type  2+ and press Enter.
  • The output should look something like the following:
  • Apache Ant version 1.8.2 compiled on December 13 2006

Installing the Force.com Migration Tool:

To download and install the Force.com Migration Tool:

  • Log into a Salesforce organization on your deployment machine. Click     and then click   % .
  • Save the .zip file locally and extract the contents to the directory of your choice.
  • Copy ant-salesforce.jar and paste into your Ant installation’s lib directory. The lib directory is located in the root folder of your Ant installation.
  • Go to control panel and click on System In System properties window, goto Advanced tab and click on Environment variables.

Create the following two environment variables if they are not existing.

  • ANT_HOME – value is (your apache-ant-1.8.2 installed path)
  • JAVA_HOME – value is (your jre1.6.0_02 installed path)
    

 Learn SalesforceOnline With Free Tutorials

GeneralSteps

The general procedure we will follow when using the Force.com Migration Tool to copy metadata from one Salesforce organization to another is:

  • Enter credentials and connection information for source Salesforce organization in build.properties
  • Create retrieve targets in build.xml
  • Construct a project manifest in package.xml
  • Run the Force.com Migration Tool to retrieve metadata files from Salesforce
  • Enter credentials and connection information for destination Salesforce organization in build.properties
  • Run the Force.com Migration Tool to deploy metadata files or deletions to Salesforce Fetching Data
Enthusiastic about exploring the skill set of Salesforce? 
Then, have a look at the blog post to gather additional knowledge on Salesforce Training Online.

To fetch the data from the source environment

Create a folder say some “Migration folder” and create the following in it.

  • build.properties.txt
  • build.xml
  • Create a new folder with the name say “retrieveSource”.
  • In the retrieveSource folder, create an xml file with the name “package.xml”.

Build.properties file should look like this Give userid, password, server url like below username = user@gehc.amer.sprintdev

password = password12jSZQVS7erefdUMfjcoFSgr7Mqx
serverurl = https://test.salesforce.com

Build.xml file should have the following

<!–Retrieve the contents from the source environment–>

<target name="retrieve">
 <mkdir dir="retrieveMetadata"/>
 <setproxy proxyport="80" proxyHost = your proxy proxyuser =
 'username' proxypassword = 'password' />
 <sf:retrieve username="${sf.username}" password="${sf.password}"
 serverurl="${sf.serverurl}" retrieveTarget="retrieveMetadata"
 unpackaged="retrieveSource/package.xml" pollWaitMillis="10000"
 maxPoll="100"/>
 </target>


<!– Deploy the changes in to destination environment –>

<target name="deploy">
 <setproxy proxyport="80" proxyHost = your proxy proxyuser =
 'username' proxypassword = 'password' />
 <sf:deploy username="${sf.username}" password="${sf.password}"
 serverurl="${sf.serverurl}" deployRoot="retrieveMetadata" />
 </target>


<!– Delete the changes made to the description environment–>

<target name="remove">
 <setproxy proxyport="80" proxyHost = your proxy proxyuser =
 'username' proxypassword = 'password' />
 <sf:deploy username="${sf.username}" password="${sf.password}"
 serverurl="${sf.serverurl}" deployRoot="remove" />
 </target>

Finally the build.xml file should look like below.

 Learn SalesforceOnline With Free Tutorials

3) Package.xml file should contain all the metadata information like objects, classes, triggers etc that needs to be migrated or retrieved.

In the source environment, just create a new field or class or trigger to verify the migration is successfully taken place in the destination environment. In the below example, the following are created in the source environment

  • MigrationTest_Field — a text field in account object
  • MigrationTestClass — a new class
  • Top_X_Designation__c — custom object

Keep all the data that needs to be retrieved from source environment in <types> like this.

<types>
 <members>Account.MigrationTest_Field__c</members>
 <name>CustomField</name>
 </types>
 To retrieve all the triggers or classes, put *. Like this
 <types>
 <members>*</members>
 <name>ApexTrigger</name>
 </types>

Finally the package.xml file should look like this

 Learn SalesforceOnline With Free Tutorials

We need to go to the command prompt and type the commands to do the following

  • Retrieve – to retrieve the data from source environment
  • Deploy – to deploy the data in to the destination environment

Go to folder directory in the command prompt where the “Migration folder” is created.

Type the following command

Type the command[ +$to fetch the data from the source environment in to the folder.

After the executing the above command, the below details are visible in the command prompt.

 Learn SalesforceOnline With Free Tutorials

Go to the source folder and verify whether all the data mentioned in the package.xml is fetched from the source environment. We will find a folder called retrieve Metadata that contains all the retrieved data from the source environment. Now, give the credentials of the destination environment in the build.properties file. And type the following command. Deploying Data

To deploy the data in to the destination environment

Type “Ant deploy” in the command prompt Now after the files are deployed, we will get the following info in the command prompt.

 Learn SalesforceOnline With Free Tutorials

Now go to the UI and check whether all the files are migrated to the destination environment.

With this example, we can see all the above provided data will be migrated and available in the destination environment.

Integrating with Subversion

Using the Subclipse IDE we can login to SVN repository and checkout the branch which we have latest code and metadata in to a local directory. As mentioned in the Fetching data section we can run deploy command to deploy the contents which are mentioned in the package.xml will get deployed to destination environment.

 Learn SalesforceOnline With Free Tutorials

For indepth understanding on Salesforce click on

Summary
Review Date
Reviewed Item
Migration
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on  MIGRATION"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.