Using Data Loader from the cmd command line

1. First, check the official article to learn how to install Data Loader 

https://help.salesforce.com/articleView?id=command_line_import_data.htm&type=5

2. Using the cmd command line to operate Data Loader requires the following five steps

1. Create an encryption key file

2. Create an encrypted password

3. Create a field mapping file

4. Create a configuration file

5. Import data

Step 1: Create an encryption key file

1. Create a key.txt and write your encryption key in it (equivalent to a password prompt, you can only use this to decode your encrypted password)

( Note: Key needs 16 digits or letters as encryption key )

Step 2: Create an encrypted password

1. Open cmd and enter the bin in the Data Loader installation directory

2. Enter the conversion command encrypt -e password encryption key location (see the figure below for details) , press Enter 

3. An encrypted secret key will be generated (this needs to be copied and saved, which will be used later)

4. Password encryption is completed, enter the next stage

Note: If the password here does not set the IP login range, it needs to be marked with security

The password is followed by a security identification code. If you do not need a security identification code when using webservice to access, you can set the IP login range in SF:

How to configure the super administrator to log in to salesforce org next time without entering the verification code: Profile -> System Administrator -> Login IP Ranges, set IP Start Address: 0.0.0.0, IP End Address: 255.255.255.255.
 

The third step, create a field mapping file

1. Copy the following to a text file and save it as  accountInsertMap.sdl  . This is a data insertion, so the data source is to the left of the equals sign and the target field is to the right. 

#Mapping values
#Thu May 26 16:19:33 GMT 2011
Name=Name
NumberOfEmployees=NumberOfEmployees
Industry=Industry

Step 4: Create a configuration file 

The process-conf.xml  file contains the information that Data Loader needs to process the data. Process-conf.xml  file  <bean> refers to a single process, such as insert, upsert or export. Therefore, this file can contain multiple procedures. In this step, you edit the file to insert the account into Salesforce.

  1. Make a copy of the process-conf.xml file from the  \samples\conf  directory . Be sure to keep a copy of the original file, as it contains examples of other types of Data Loader processing such as upserts and exports.  

2. Open the file in a text editor and replace the content with the following XML:

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="accountInsert"
        class="com.salesforce.dataloader.process.ProcessRunner"
        singleton="false">
        <description>accountInsert job gets the account record from the CSV file 
            and inserts it into Salesforce.</description>
        <property name="name" value="accountInsert"/>
        <property name="configOverrideMap">
            <map>
                <entry key="sfdc.debugMessages" value="true"/>
                <entry key="sfdc.debugMessagesFile" 
                    value="C:\Users\pc\dataloader\v47.0.0\Log\accountInsertSoapTrace.log"/>
                <entry key="sfdc.endpoint" value="https://ap8.salesforce.com/"/>
                <entry key="sfdc.username" value="[email protected]"/>
                <!--Password below has been encrypted using key file, 
                    therefore, it will not work without the key setting: 
                    process.encryptionKeyFile.
                    The password is not a valid encrypted value, 
                    please generate the real value using the encrypt.bat utility -->
                <entry key="sfdc.password" value="dd4a13ad269174ef15b8622ad7475eea62471fb41998895ff2ff447c267fb115"/>
                <entry key="process.encryptionKeyFile" 
                    value="C:\test\Key.txt"/>
                <entry key="sfdc.timeoutSecs" value="600"/>
                <entry key="sfdc.loadBatchSize" value="200"/>
                <entry key="sfdc.entity" value="Account"/>
                <entry key="process.operation" value="insert"/>
                <entry key="process.mappingFile" 
                    value="C:\Users\pc\dataloader\v47.0.0\samples\conf\accountInsertMap.sdl"/>
                <entry key="dataAccess.name" 
                    value="C:\Users\pc\dataloader\v47.0.0\account.csv"/>
                <entry key="process.outputSuccess" 
                    value="C:\Users\pc\dataloader\v47.0.0\Log\accountInsert_success.csv"/>
                <entry key="process.outputError" 
                    value="C:\Users\pc\dataloader\v47.0.0\Log\accountInsert_error.csv\"/>
                <entry key="dataAccess.type" value="csvRead"/>
                <entry key="process.initialLastRunDate" 
                    value="2005-12-01T00:00:00.000-0800"/>
            </map>
        </property>
    </bean>
</beans>

3. Modify  the following parameters in the process-conf.xml  file. For more information on process configuration parameters, see Data Loader Process Configuration Parameters .

  • sfdc.endpoint—Enter the URL of the Salesforce instance for your organization; for example, https://yourInstance.salesforce.com/.
  • sfdc.username—Enter the username that Data Loader uses to log in.
  • sfdc.password—Enter the encrypted password value you created in step 2.
  • process.mappingFile- Enter the path and filename of the mapping file.
  • dataAccess.Name- Enter the path and filename of the data file containing the customers you want to import.
  • sfdc.debugMessages- Currently set to (true) for troubleshooting . Set to when your import has started and is running . true false
  • sfdc.debugMessagesFile- Enter the path and filename of the command line log file.
  • process.outputSuccess- Enter the path and filename of the success log file.
  • process.outputError- Enter the path and filename of the error log file.

Step 5 Import data 

1. Copy the following data to a file named  accountInsert.csv  . This is the customer data that you will import into your organization.

Name,Industry,NumberOfEmployees
Dickenson plc,Consulting,120
GenePoint,Biotechnology,265
Express Logistics and Transport,Transportation,12300
Grand Hotels & Resorts Ltd,Hospitality,5600

In the Command Prompt window, enter the following command:

process.bat "<file path to process-conf.xml>" <process name>

  • Replace <file path to process-conf.xml> with the directory path containing  process-conf.xml . 
  • Replace <process name> with the process specified in  process-conf.xml . 

Your command should look like this:

process.bat "C:\Users\pc\dataloader\v47.0.0\samples\conf" accountInsert

After the process runs, the Command Prompt window displays success and error messages. You can also check the log files: insertAccounts_success.csv  and  insertAccounts_error.csv . After successfully running the process, the insertAccounts_success.csv  file contains the records you imported with the ID and status of each record

Through the printing of CMD, we can know that these four have been successfully inserted into the SF system.

Log in to SF and view customers. You can see that these four pieces of data have come in.

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324093400&siteId=291194637