Friday, July 28, 2017

Apex Data Loader

  • Data Loader is a client application for the bulk import or export of data. (Up to 5 million records)
  • Use it to insert, update, delete, or export Salesforce records.
  • When importing data, Data Loader reads, extracts, and loads data from comma separated values (CSV) files or from a database connection.
  • When exporting data, it outputs CSV files.

Note: If commas are not appropriate for our locale, use a tab or other delimiter.

We can use Data Loader in two different ways:

User interface—When we use the user interface, we work interactively to specify the configuration parameters, CSV files used for import and export, and the field mappings that map the field names in your import file with the field names in Salesforce.

Command line—When you use the command line, you specify the configuration, data sources, mappings, and actions in files. This enables you to set up Data Loader for automated processing.

Data Loader offers the following key features:
• An easy-to-use wizard interface for interactive use
• An alternate command line interface for automated batch operations
• Support for large files with up to 5 million records
• Drag-and-drop field mapping
• Support for all objects, including custom objects
• Can be used to process data in both Salesforce and
• Detailed success and error log files in CSV format
• A built-in CSV file viewer
• Support for Windows 7

Use Data Loader when:
* You need to load 50,000 to 5 million records.
* Data Loader is supported for loads of up to 5 million records.
* If you need to load more than 5 million records, we recommend you work with a partner or visit the App Exchange for a suitable partner product.
* You need to load into an object that is not yet supported by the import wizards.
* You want to schedule regular data loads, such as nightly imports.
* You want to export your data for backup purposes.

Use the import wizards when:
• You are loading less than 50,000 records.
• The object you need to import is supported by import wizards.
* To see import wizards click Your Name > Setup > Data Management.
• You want to prevent duplicates by uploading records according to account name and site, contact email address, or lead email address.

Login Considerations
* If your organization restricts IP addresses, logins from untrusted IPs are blocked until they’re activated.
* Salesforce automatically sends you an activation email that you can use to log in. The email contains a security token that you must add to the end of your password.
* For example, if your password is mypassword, and your security token is XXXXXXXXXX, you must enter mypasswordXXXXXXXXXX to log in.

Configuring Data Loader
Use the Settings menu to change the default operation settings of Data Loader.
1. Start Data Loader by choosing Start > Programs > > Data Loader > Data Loader.
2. Choose Settings > Settings.
3. Edit the fields as desired:

Batch size
* In a single insert, update, upsert, or delete operation, records moving to or from Salesforce are processed in increments of this size.
*The maximum value is 200. We recommend a value between 50 and 100.
*The maximum value is 10,000 if the Use Bulk API option is selected.
Insert null values
*Select this option to insert blank mapped values as null values during data operations.
* Note that when you are updating records, this option instructs Data Loader to overwrite any existing data in mapped fields.
*This option is not available if the Use Bulk API option is selected.
*Empty field values are ignored when you update records using the Bulk API.
* To set a field value to null when the Use Bulk API option is selected, use a field value of #N/A.
Assignment rule
*Specify the ID of the assignment rule to use for inserts, updates, and upserts.
* This option applies to inserts, updates and upserts on cases and leads.
* It also applies to updates on accounts if your organization has territory assignment rules on accounts.
*The assignment rule overrides Owner values in your CSV file.
Server host
*Enter the URL of the Salesforce server with which you want to communicate.
* For example, if you are loading data into a sandbox, change the URL to
Specify how many seconds Data Loader waits to receive a response back from the server before returning an error for the request.
Query request size
*In a single export or query operation, records are returned from Salesforce in increments of this size.
*The maximum value is 2,000 records. Larger values may improve
performance but use more memory on the client.
Allow field truncation
*Select this option to truncate data in the following types of fields when loading that data into Salesforce: Email, Multi-select Picklist, Phone, Picklist, Text, and Text(Encrypted).
*This option is not available if the Use Bulk API option is selected. In that case, the load operation fails for the row if a value is specified that is too large for the field.

Use Bulk API
*Select this option to use the Bulk API to insert, update, upsert, delete, and hard delete records.
*The Bulk API is optimized to load or delete a large number of records asynchronously.
*It’s faster than the default SOAP-based  API due to parallel processing and fewer network round-trips.
*When you select the Hard Delete operation, the deleted records are not stored in the Recycle Bin.
*Instead, they become immediately eligible for deletion.
*The permission for this operation, “Bulk API Hard Delete,” is disabled by
default and must be enabled by an administrator.
*A Salesforce user license is required for hard delete.
Enable serial mode for Bulk API
*Select this option to use serial instead of parallel processing for Bulk API. *Processing in parallel can cause database contention. When this is severe, the load may fail.
* Using serial mode guarantees that batches are processed one at a time.  
* Note that using this option may significantly increase the processing time for a load.
*This option is only available if the Use Bulk API option is selected.
Upload Bulk API Batch as Zip File
*Select this option to use Bulk API to upload zip files containing binary attachments, such as Attachment records or Salesforce CRM Content.
*This option is only available if the Use Bulk API option is selected.

To configure Data Loader to use the Bulk API for inserting, updating, upserting, deleting, and hard deleting records:
1. Start Data Loader by choosing Start > Programs > > Data Loader > Data Loader.
2. Choose Settings > Settings.
3. Select the Use Bulk API option.
4. Click OK.