Once you are done with your development you need to migrate your code from your development organization to the organization where business user can use your code. So in this tutorial we will learn different types of organization and Salesforce Deployment Methods from one organization to another organization.

1. Organization Type

Salesforce provides two types of organization

a) Production (This is Production where end user or business user use Salesforce System)

b) UAT Sandbox (UAT stands for User Acceptance Testing and this organization used by business user to do final testing before  code move to Production Organization).

c) Developer Sandbox: This Sandbox is Used to Start Development.

2. Deployment type

There are 3 ways to deploy or migrate code from one organization to another organization

a) Change set

Change set is standard and point and click method do deploy code and migrate code. This is useful and recommended when you are new to Salesforce.

b) Eclipse IDE

Eclipse IDE deployment is easy to use where you can migrate code with easy steps but this deployment method is recommended only if you have less number of test classes. If you have more than 100 classes eclipse generally hang and doesn’t show any progress.

c) Force.com Ant Migration Tool

Force.com Ant migration tool provides more control over deployment and developer find it very complex but the truth is it is not that much complex if step by step procedure followed.

Step 1 : You need to install Java SDK

Step 2 : Download Ant from http://apache.mirrors.ionfish.org//ant/binaries/apache-ant-1.9.6-bin.zip

Step 3 : Extract Step 2 Zip file in C:\ directory. It will create a new directory called Apache-Ant. Setup Ant Home Path in your windows environment as shown below

Salesforce Deployment Methods

Step 4 : Download Force.com Migration tool as shown in below screenshot.

Salesforce Ant Deployment

Step 5 : Copy ant-salesforce.jar from step 4 and copy this in Ant lib folder and Sample folder in Apache-ant folder from zip folder

Salesforce Deployment Methods

Step 6 : Create Build.xml file with following code.

<project xmlns:sf="antlib:com.salesforce" basedir="." default="test" name="UAT Backup">

 <target name="retrieve"> <mkdir dir="retrieveMetadata"/> 

<sf:retrieve username="YOURPRODUSERNAME" password="YOUR SANDBOX PASSWORD AND SECURITY TOKEN" serverurl="https://test.salesforce.com" retrieveTarget="retrieveMetadata" unpackaged="retrieveSource/package.xml"/> </target> 

<target name="deploy"> 

<sf:deploy username="YOURPRODUSERNAME" password="YOURPRODUCTIONPASSWORD AND SECURITY TOKEN" checkOnly="false" serverurl="https://login.salesforce.com" deployRoot="retrieveMetadata" logType="Detail"/> 

</target> 

</project> 

Step 7 : Replace username and password in Step6 code with your username and password.

Step 8 : Create a new folder in Sample folder and name it as retrieveSource.

Step 9: Copy following code to create a package.xml file inside retriveSource folder, you can follow Force.com migration guide to generate and add more component in package.xml.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>ClassName1</members>
        <members>ClassName2</members></pre>
<pre><name>ApexClass</name> </types>
<types>
<members>Trigger1</members>
<members>Trigger2</members>
 <name>ApexTrigger</name>
</types>
<version>30.0</version>
</Package>

Step 8 : Open Command prompt and go to c:\apache-ant\sample directory and type ant retrieve. It will create a new directory called retrieveMetadata.

Step 9 : To deploy to target organization type ant deploy. Your deployment will start and new code will be available in target organization.

I hope this tutorials helped you to know about various Salesforce Deployment Methods.

Happy Development!