Data loader is a tool provided by the salesforce so that we can perform various functions through it. The functions could be insert, update, delete, export, export all, upsert. This is a migration tool which is used to migrate data more than 50,000 in number, but a drawback of it is that it cannot scheduled.
Thus to overcome this drawback we make use of dataloader through command line interface which is scheduled with task manager.
The most important part of setting up Salesforce Command Line Data loader is to generate the encrypted password using utility provided by the Data Loader.
Before we start with the steps we in data loader cli need to create a folder (with any name, I used dataloader) which should have files with names.
5) AccountInsertMap.sdl or with csv extension.
Steps to schedule data loader in Salesforce
Create Encryption Key
1. Open a command prompt.
2. In the cmd enter cd\ to navigate to the root directory of the drive where the dataloader is installed.
3. Enter to the bin through this command.
Cd C:\Program Files(x86)\salesforce.com\Apex Data Loader 22.0\bin
4. Generate an encryption Key
Encrypt.bat “g <seedtext>
Replace seedtext with any string.
Create the encrypted password.
In the same command prompt you have the following command:
Encrypt.bat <password> <filepath>\ key.txt
Replace with the password with which the dataloader login to salesforce and replace the filepath with the key.txt path.
Copy the encrypted password that is generated by the command prompt. We will discuss this later.
Create a mapping file with name accountInsertMap.sdl or a csv file. The data is insert so that the left hand side data is equal to the destination field on right hand side.
#Thu May 26 16:19:33 GMT 2011
Create configuration file
Contains all the information the data loader needs to perform. Each bean of the config file perform individual function such as insert, delete, update etc. We perform export from the following file.
Parameters for Process-config.xml:
Sfdc .endpoint:-Enter the URL of the Salesforce instance for your organization, for example
sfdc.username:-Enter the username with which your login to dataloader.
Sfdc.password: -Enter the password encrypted password which you create in step 2.
dataAccess.Name: -Enter the path and file name of the data file that contains the Accounts that you want to import.
The process-con file should be present in the dataloader folder.
1) Copy the following data to the filename accountInsert.csv. This is the account data which can be imported into the organization. You can have your own values.
Name, Number of Employees, Industry
Dickenson plc, 120, Consulting
Gene Point, 265, Biotechnology
Express Logistics and Transport, 12300, Transportation
Grand Hotels & Resorts Ltd, 5600, Hospitality
2)In the command prompt window, we have the following command.
Process.bat <path to process-con.xml> process name
Provide the path to process-con.xml and in the process provide the name of the process name.
In our case the process name will be insertAccounts as is present in the process-con.xml file.
<property name=”name” value=”insertAccounts”/>
After the process runs the command prompt enter the success and error messages.
You can also check with the log files with the names success.csv and error.csv
The execution of the command also creates a log file, as the path needs to be given where the log file need to be created.
<entry key=”sfdc.debugMessagesFile” value=”C:\Users\Desktop\data loader\log\accountInsertSoaptrace.log”/>
Now another step is quite essential to schedule the command line dataloader, for this we require a bat file named as process.bat. This bat file contains path till bin and the path for the process-con.xml
This bat file should be present in the dataloader folder.
Steps of Scheduling dataloader through windows: –
Click on start->control panel->System and security->Administrative tools->Task scheduler.
1) Click on create task in actions.
2) Provide the name of the schedule task.
3) Set up trigger timings as required to schedule the data loader jobs.
4) Set up an action with action type as Start Program and add process.bat file.
5) Save the task.
The scheduler will run the data loader processes as per the trigger time set in windows scheduler task. This is how we schedule data loader through command line interface.