How to retrieve Components in Bulk in Salesforce?

Asked 06-Feb-2018
Updated 06-Feb-2018
Viewed 625 times

1 Answer


Retrieving component is the optimal way to download a large number of components of a single metadata type, such as custom reports, into a set of local files.

Below are the following parameters which may be set for each <sf:bulkRetrieve> target:

Field Description
Username  this field is required if SessionId is not specified. The Salesforce username is used for login. The username field associated with this connection must have the “Modify All Data” permission. Typically, this permission is enabled only for the User having rights of System Administrator.
Password this field is required if SessionId is not specified. The Password we use to log in to the organization associated with this project. If we are using a security token, paste the 25-digit token value to the end of your password.
SessionId  this field is required if Username and Password are not specified. The active SessionId of the Salesforce or the OAuth access token. After a User log-in, a session is created into the Salesforce successfully with a Username and Password. To log in to an existing session use a SessionID instead of creating a new session. You can use Access Token instead of using OAuth authentication. To know more about the Authentication Apps, then see Authenticating Apps with OAuth in the Salesforce Help.
ServerUrl  this field is Optional, In the Salesforce Server URL (if it is blank, then its default go to After that to connect to a sandbox instance, change this value to
RetrieveTarget  this field is Required if the Root of the directory structure into which the metadata files are retrieved.
MetadataType – this field is Required if the name of the metadata type to be retrieved; for example, CustomObject for custom objects, or Report for custom reports. For a full list of allowed values, see Component Types.
ContainingFolder  this field is also an Optional field, so if the metadata is contained in a folder, this parameter should be the name of the folder from which the contents are retrieved.
batchSize  this field is also an Optional field, the default value of the batchSize field is to 10, then after the number of items to retrieve while doing multi-part retrieve.
apiVersion  this field is also an Optional field, so the Metadata API version to use for the retrieved metadata files, and the default value is 42.0.
maxPoll  this field is an Optional field and its default value is to 200. Now, the number of times to poll the server for the results of the retrieve request, then the clients must wait for two seconds after the first poll attempt. And the wait time is doubled for each successive poll attempt up to a maximum of 30 seconds between poll attempts.
Unzip  this field is an Optional field and its default value will be true. If it is set to true, then the retrieved components will be unzipped, otherwise, if Unzip field is set to false, then the retrieved components are saved as a zip file in the retrieveTarget directory.

At last, the custom report of components are retrieved in bulk but is To retrieve custom report components in bulk, specify a target in the build.xml file using <sf:bulkRetrieve>.

view sourceprint?
<target name="bulkRetrieve">