Newer Version Available

This content describes an older version of this product. View Latest

Understanding retrieveCode

Use the retrieveCode call to retrieve classes and triggers from your sandbox or production organization. During the normal deploy cycle, you would run retrieveCode prior to deploy, in order to obtain the correct directory structure for your new classes and triggers. However, for this example, deploy is used first, to ensure that there is something to retrieve.

To retrieve classes and triggers from an existing organization, use the retrieve ant task as illustrated by the sample build target ant retrieveCode:

The file codepkg/package.xml lists the metadata components to be retrieved. In this example, it retrieves two classes and one trigger. The retrieved files are put into the directory codepkg, overwriting everything already in the directory.

The properties of the retrieve task are as follows:

username
The username for logging into the Salesforce production organization.
password
The password associated for logging into the Salesforce production organization.
serverURL
The URL for the Salesforce server you are logging into. If you do not specify a value, the default is www.salesforce.com.
apiversion
Which version of the Metadata API at which the files should be retrieved.
retrieveTarget
The directory into which the files should be copied.
unpackaged
The name of file that contains the list of files that should be retrieved. You should either specify this parameter or packageNames.
packageNames
The name of the package or packages that should be retrieved.
Table 1. build.xml retrieve target field settings
Field Description
username Required. The Salesforce username for login.
password Required. The username you use to log into the organization associated with this project. If you are using a security token, paste the 25-digit token value to the end of your password. The username associated with this connection must have the “Modify All Data” permission. Typically, this is only enabled for System Administrator users.
serverurl Optional. The salesforce server URL (if blank, defaults to www.salesforce.com). For a sandbox, use test.salesforce.com.
pollWaitMillis Optional, defaults to 5000. The number of milliseconds to wait between each poll of salesforce.com to retrieve the results.
maxPoll Optional, defaults to 10. The number of times to poll salesforce.com for the results of the report.
retrieveTarget Required. The root of the directory structure to retrieve the metadata files into.
unpackaged Optional. The name of a file manifest that specifies the components to retrieve.
singlePackage Optional, defaults to false. Specifies whether the contents being retrieved are a single package.
packageNames Optional. A list of the names of the packages to retrieve.
specificFiles Optional. A list of file names to retrieve.