Using the Data Import Wizard

Once you have created an export file and cleaned up the data for import, follow these steps to import data using the Data Import Wizard:

  1. To start the wizard, perform the following steps:
    • From Setup, go to Administration Setup | Data Management | Data Import Wizard.
    • Click on Launch Wizard!
  2. Choose the data that you want to import from the following:
    • We can import accounts, contacts, leads, and solutions from the Standard Object tab and other objects from the Custom Objects tab.
    • Next, we need to specify whether we want to add new records, update existing records, or add and update records simultaneously.
    • Specify matching and other criteria. We will be matching records using their Salesforce ID.
    • In the last section, we will specify the file that contains the data.
    • Choose the character encoding method for your file. Most users will not need to change their character encoding.
    • Click on Next.
    Using the Data Import Wizard
  3. On the next screen, we are going to map the data fields to the Salesforce data fields.
  4. The Data Import Wizard automatically tries to map as many data fields as possible to the standard Salesforce data fields. If some fields are unmapped, we need to map them manually:
    Using the Data Import Wizard
  5. The fields that are unmapped are highlighted in RED in the second column. We can click on the Map link on the left-hand side of the page to manually map these fields.

    Select the Salesforce field to the map the column with:

    Using the Data Import Wizard

    To change the field mapping that Salesforce has already mapped, click on the Change link. Then click on Next

  6. To start the import, perform the following steps:

    On the next screen, the Import wizard will highlight the mapped fields and unmapped fields. It will also highlight the errors, if there are any, in the data. If everything is correct, click on start import:

    Using the Data Import Wizard

Apex data loader

The Apex data loader is a utility used to upload data to the organization. We can load any object that has API_Access. Unlike other tools, the data loader is not a cloud-based tool, but a desktop utility built for systems running on desktop systems. Some features of the data loader are as follows:

  • The Apex data loader is available in unlimited edition, enterprise edition, and developer edition orgs
  • It supports the CSV (Comma Separated Value) format to load data and export data
  • It is a useful tool for backing up and archiving your office data
  • The data loader also runs on the command line

Some salient features of the data loader are listed as follows:

  • The Apex data loader is an API-based tool used to load Salesforce data
  • We can load more than 50,000 records using it and also schedule data loads
  • Data can be exported and mass deleted
  • The Apex data loader can run from the command line
  • We can export data for backup and mass delete
  • We can also schedule the data loading at regular intervals
  • Data can be imported and exported using CSV and JDBC

Downloading the data loader

Unlike the other features of Force.com, the data loader is not completely on the cloud. We need to physically download and install it on the machine to use it. To obtain and install the data loader, perform the following steps:

  1. Navigate to User name | Setup | Data Management | Data Loader.
  2. Download the Data Loader.
  3. Launch Install Shield Wizard and follow the instructions.

Install the data loader in the machine before proceeding to the next section. In the next section, we will be loading data.

Using the data loader

The data loader helps us export data for backup, insert data, delete, and hard delete the data, as shown in the following screenshot:

Using the data loader

Let's export some opportunities for the purpose of an example:

  1. Click on Export on the Apex Data Loader.
  2. If you are not logged in, it will ask for a login. Ensure that you append the security token to the password, as shown in the following screenshot, and click on Next.
    Using the data loader
  3. Select the object to extract the data from and the folder in which the data should be extracted. Ensure that you give the filename as .csv, as shown in the following screenshot, and click on Next.
    Using the data loader
  4. Prepare the query, as shown in the next screenshot. Select the fields to be downloaded from the field chooser situated on the left-hand side of the screen. We can add conditions to the query using the condition box on the right-hand side of the screen.
  5. Don't forget to click on the Add condition button to add the condition to the query.
  6. The final query is formed in the wide input textbox, which includes the fields and the conditions:
    Using the data loader
  7. Click on Finish, and it will start extracting. If there are any errors, the final report will show two files: success.csv and error.csv.
  8. Error files will have the reason for the error in the last column.
  9. The finished data will be extracted to the file.

Upserting data

Now that we have exported the data, let's try to upsert the data. We are going to use the same export file as a template to upsert new records. It is easier to map fields on an exported file because Salesforce can automatically map the records.

Perform the following steps to upsert the data:

  1. Click on the Upsert button on the main screen of Data Loader, select the object to upsert, and click on Next:
    Upserting data
  2. On the next screen, choose the matching ID. If there is an external ID field defined in the drop-down menu, there will be an option to select the external ID. This ID is used to determine the duplicates before loading.
    Upserting data
  3. On the next page, we prepare the mapping to map the fields in the CSV file to the fields in the object. As shown in the following screenshot, click on Create or Edit a map. We can also save this map for future use.
    Upserting data
  4. As shown in the following screenshot, we can map the Salesforce fields displayed on the top to the fields in Excel displayed at the bottom:
    Upserting data
  5. Drag the respective fields from the Salesforce object over the fields from the CSV file. If the column headers in Excel are the same, we can directly click on the Auto-Match Fields to Columns button.
  6. We can also save the mappings in an external file for future use. Finish the mappings and click on Next:
    Upserting data
  7. The wizard asks you to choose a directory in the next screen. This directory is where the success and error files are created. If some new records are inserted, the success file comes with the ID of these new records while the error file comes back with the error code:
    Upserting data
  8. Select the Directory and click on Finish.

Thus, we have seen the commands of export and upsert using the data loader. The commands of insert and update are very similar to upsert. However, they won't allow mapping with an external ID. The operations of delete and update require a Salesforce ID.

Setting up the data loader

By default, the data loader is configured to operate using some default parameters. We can further configure it as per our requirements to improve performance.

The data loader by default works only with the production organization. To make it operable with the sandbox, we need to modify some parameters. Let's configure the data loader for the sandbox operation.

Go to Settings | Settings in the Data Loader. A new window will open, as shown in the following screenshot:

Setting up the data loader

There are five major configuration changes that we need to keep in mind while setting up the Data Loader. Let's take a look at each one of them:

  1. Server host (clear for default): The server host is the endpoint URL where the data loader should be connected. By default, the server host would be https://login.salesforce.com. This endpoint URL is used when we upload data to the production organization or the free developer edition. However, when we upload data to sandbox, we need to change it to https://test.salesforce.com.
  2. Use the bulk API: By default, the maximum Batch size (5) is 200 while uploading using the data loader; however, if the data is large, we can use the bulk API, which increases the batch size to 2,000.
  3. Start at row: If our batch operations are suddenly interrupted at any point, the record number is indicated on the label of this field. We can choose to resume the operation from this number.
  4. Insert null values: When we upload the data using the data loader, we need to specify whether the blank spaces should be treated as null values. This is especially helpful while inserting the Date and Date/Time fields. When using the bulk API, if there are any blank values, they are simply ignored. Therefore, to insert NULL, we need to replace all the blanks with #NA.
  5. Batch size: The data loader loads data in batches of fixed size. The maximum batch size of a normal data loader is 200, while the maximum batch size of loading using bulk API is 2,000. With batches, multiple records are inserted in a single shot; for example, if we are loading 1,000 records, the data loader will chunk the data into five batches, 200 records each. However, the data import wizard can do the same operation in just a single request. We can reduce the batch size, but we cannot increase it beyond the maximum limit.

Using the data loader through the command line

The data loader is a very easy and intuitive tool used to load data. As it is easy to use, it also requires manual intervention and user input to operate. However, many times, we require an automated process to upload large chunks of data. For these cases, we use the data loader through the command-line interface.

The command-line data loader performs the same operations as the normal data loader without the GUI and the easy-to-use interface.

Configuring the command-line data loader

Before we fire up the data loader with the command-line interface, we need to configure it so that it can perform the desired operations.

The main configuration file is the config.properties file, which is located in the Data Loader folder. The default location of the data loader is c:Program FilessalesForce.comApex Data Loader 35.0.

For help with using the command line, the data loader provides the -help command.

As the command-line data loader runs on Command Prompt, we have very few options to customize and format the commands during the operation. To overcome this, we prepare some files that store the basic commands and configuration needed to run the data loader from the command line. Let's take a look at some of the files used in the operation.

Preparing the process-conf.xml file

The process-conf.xml file contains a description for every potential process that can be called from the command line. Each of these processes is referred to as a Process Bean. A sample Process-conf.xml file is shown in the following screenshot:

Preparing the process-conf.xml file

The section marked in the outer rectangle is a single process bean that holds the data operation. The following are its main properties:

  • Name: This is used to identify the bean in the config.properties file and when we call it from the command-line interface, for example, accountMasterProcess.
  • sfdc.entity: The Salesforce object that is the target of the actions. The value of this property is case-sensitive. For example, Account (note: Capital A).
  • process.operation: This attribute identifies the type of operation, for example, insert, upsert, update, and so on.
  • process.mappingFile: This attribute identifies the mapping between the fields in the source file (dataAccess.name) and the Salesforce object. This mapping file is an .sdl file. This file can be easily created from the GUI of the data loader.
  • dataAccess.type: This attribute identifies the operation to be performed on the source file. For example, if we are using the ODBC data source, the property will read databaseRead; if we are including data from CSV, the property will be CSVRead.
  • sfdc.username: This stores the Force.com login name for the command line run. If there is no owner name record specified, this will be the new owner.
  • sfdc.password: The configuration file is stored as a plain text on the machine; storing the password in the file is not a good and secure way. sfdc.password and process.encryptionKeyFile serve the purpose of encrypting the password for added security. To generate the key and the encrypted password, the data loader provides the Encrypt.bat utility with its installation. We will take a look at the Encrypt.bat file in the next section.

These are the entities in the process-conf.xml file. This file has to be prepared every time we need to perform an operation. If we need to perform multiple operations in one go, the entire <bean> </bean> should be repeated with all the parameters inside it.

After we configure the desired files, we are now ready to run the operation. To run the command-line job, the data loader comes with a process.bat file kept in the Data loader folderin folder.

To run the batch process, we run the process using the name of the command as input, process ../accountMasterProcess

In this case, process is the command given to run the data loader and accountMasterProcess is the name given to the ID in the Bean attribute.

Encrypting a password using Encrypt.bat

To log in to the Salesforce.com organization, we need to specify the password in the config.properties file. For security purposes, the password should be stored after encryption so that no unauthorized person can read it.

Salesforce provides us with the encrypt.bat utility, which encrypts the password from the plain text. The utility is available at the Data loader folderinencrypt.bat default location.

encrypt.bat runs in the command line and supports the following commands:

  • Generate a key: This command generates a key from the text we provide. Usually, we should provide the password with the security code in plain text format to generate an encrypted key.
  • Encrypt text: This command performs the same operation as generating a key; it can only be used to encrypt the general text provided.
  • Verify encrypted text: This command matches plain text and the encrypted password and prints a success or failure message.

Troubleshooting the data loader

If there is some error in the operation of the data loader, we can access the log files of the data loader. The two log files are as follows:

  • sdl.log: This contains a detailed chronological list of data loader log entries. Log entries marked as INFO are procedural items, such as logging in to Salesforce. Log entries marked as ERROR are problems, such as a submitted record missing a required field.
  • sdl_out.log: This is a supplemental log that contains additional information not captured in sdl.log. For example, it includes log entries for the creation of proxy server network connections.

These files are present in the temp folder of the system running on Microsoft Windows and can be accessed by entering %TEMP%sdl.log and %TEMP%sdl_out.log in the Run dialog box.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.143.65