Tips for ANT deployment in Salesforce

The Force.com Migration Tool is a Java/Ant-based command-line utility for moving metadata between a local directory and a Salesforce organization. Hope many of them using this tool for the deployment.In this post I am not going to explain how to install and configure the tool.To know more about installation and configuration please click here. If you are using this tool below are the some tips which will help you in your deployment.

 

1.For the relationship fields(Lookup,Master-detail) if the 'field history' is enable in the source org.After the retrial of the component we need to disable field history for the relationship fields.If you didn't disable and you try to deploy then you will get below error message on the Candidate field. 

Error message:

Error: duplicate value found: <unknown> duplicates value on record with id: <unknown> (line 522, column 13)

Sample XML:

<fields>

        <fullName>Candidate__c</fullName>

        <deleteConstraint>SetNull</deleteConstraint>

        <externalId>false</externalId>

        <label>Candidate</label>

        <referenceTo>Candidate__c</referenceTo>

        <relationshipLabel>Applicants</relationshipLabel>

        <relationshipName>Applicants</relationshipName>

        <required>false</required>

        <trackHistory>True</trackHistory>

        <trackTrending>false</trackTrending>

        <type>Lookup</type>

    </fields>

2.Manually delete from the directory tree the files of components which are not specified in package.xml. For example in the source org folder you have metadata of custom objects,work flow and approval process. But in your Package.xml file you specified only the custom objects for the deployment.So, you have to delete the work flow and approval process folder from source org folder. If not you will get below error message in all the component which you are deploying. 

Error message :

Force.com Migration Tool - "Not in package.xml"

 

3.If source org has some feature enabled then in the target org we need to enable that same feature or we need to remove the featured component from the XML before deploying the component.For example Multi currency feature.

 

4.There should not be any class which is named as 'Test' in the class folder of root(Source org folder) deployment directory. This will cause deployment failure while deploying the test class.

Error message:

Test.StartTest() method is not definied.

 

5. Remove the component from the source folder if you don't want to deploy it to production.

 

6. If the visualforce pages are using some variable and method. If those variable and methods are not declared in the page controller then the deployment will fail with below error.To fix this error re compile the page. 

Error message:

[sf:deploy] 3.  pages/Examplepage.page -- Error: /apex/Examplepage @7,84 action="#{SaveExamplePage}": Unknown method 'controller.SaveExamplePage()'

 

There may be many other tips like this if you know anything please comment here. So, that it will be helpful for others. 

 

Reference links:

1. http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf

2. https://success.salesforce.com/issues_view?id=a1p30000000SwXNAA0

Rating: 
No votes yet