How to retrieve Components in Bulk in Salesforce?

0 votes
186 views
Sylvester Balchunas asked 06-Feb-2018 in SalesForce by Sylvester Balchunas
edited 06-Feb-2018 by Sylvester-Balchunas

How to retrieve Components in Bulk in Salesforce?

1 Answer

0 votes
Tarun Gautam answered 07-Feb-2018 by Tarun Gautam

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 login.salesforce.com). After that to connect to a sandbox instance, change this value to test.salesforce.com.
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">
  <sf:bulkRetrieve
    username="${sf.username}"
    password="${sf.password}"
    sessionId="${sf.sessionId}"
    serverurl="${sf.serverurl}"
    metadataType="Report"
    retrieveTarget="retrieveUnpackaged"/>
</target>