Tuesday, June 14, 2016

Data Load through Command line Interface in Salesforce


Purpose: To insert, extract and then delete Accounts records from Salesforce.

Steps to, install data loader.

1.       Download Apex data loader. Navigate to Set up->Administration Set up->Data management->Data Loader. Click on Download Data Loader link.
2.       Install apex data loader setup.  C:\Program Files (x86)\salesforce.com\Apex Data Loader 23.0 will be default location while installing.

Below are the steps in order to achieve our requirement:

1. Create a folder and name it as “data Loader Demo” in E drive.
2. Generate Key File.
Open Command Prompt (Go to run-type cmd press enter), change directory to bin:
cd Program Files (x86)\salesforce.com\Apex Data Loader 23.0\bin>   press enter
Now type :
Encrypt   –g  randomtext


key will be generated, copy the key in notepad and save it as keyToEncrypt.txt in data Loader Demo folder. Note the path of this Key.txt file. In our case path is E:\Data Loader Demo\keyToEncrypt.txt

3. Encrypt Password and security token.
In command prompt, type
Encrypt   –e password+securitytoken  “ path of key.txt file”
For example:
Encrypt  –e  xxxxxx129k19YRftloxFbgBMkb6NZsNK  “E:\Data Loader Demo\keyToEncrypt.txt"



Save the encrypted password for later use.
In our case generated password is:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx6c75bb5c73f60175181c7aa5d1441aee65c

4. Create 4 new  folders as Mapping files, Log files, extracted Accounts and Account data      folder in Data Loader demo folder


Create mapping files for insert and delete from Apex Data Loader GUI and copy paste in Mapping files folder


Create insertAccounts.csv file in Account data folder which will be inserted into salesforce.


Log files folder will be used to store success and error files.

5. Copy config.properties from below mentioned directory:
C:\Program Files (x86)\salesforce.com\Apex Data Loader 23.0\conf


Paste this file in “Data Loader Demo” folder.

Also copy process-conf.xml file from below mention directory to “Data Loader Demo folder”
C:\Program Files (x86)\salesforce.com\Apex Data Loader 23.0\samples\conf


Data Loader Demo folder:


6. Now edit process-conf.xml file in notepad:


7. Create Batch file to do the operation in bin folder.

Create a new text file with following content:

call process "E:\Data Loader Demo" accountInsert
call process "E:\Data Loader Demo" csvAccountExtractProcess
call process "E:\Data Loader Demo" AccountDeleteProcess


Save the file as autorundataloadcommandlineinterface.bat and store it in bin folder
Path : C:\Program Files (x86)\salesforce.com\Apex Data Loader 23.0\bin
     

8. Run the batch.
Open cmd, change the directory to bin “C:\Program Files (x86)\salesforce.com\Apex Data Loader 23.0\bin” and type autorundataloadcommandlineinterface.bat, and press enter



OR you can double click on bat file to execute the process.

Now check your log files and extracted Accounts folder to see success and error files and extracted account file.


Steps to schedule the data upload process or to start execution of bat file

1. Control Panel->System and Security->Administrative Tools->task scheduler->create basic task->







Browse > C:\Program Files (x86)\salesforce.com\Apex Data Loader 23.0\bin \autorundataloadcommandlineinterface.bat file and click next


            Click on finish.



7 comments:

  1. Good one. Its simple and clear

    ReplyDelete
  2. Is there any way to store the extracted file with today's date or time value along with file name ??

    ReplyDelete
  3. The article provided by you is very nice and it is very helpful to know the more information about salesforce .keep update with your blogs.....
    online form builder for salesforce

    ReplyDelete
  4. I am getting access denied to mapping file.

    ReplyDelete
  5. Hi ,
    I need to send email if any error will come

    ReplyDelete
  6. Masha Allah post padh kar kaafi jankari hasil huyi.

    ReplyDelete
  7. Discover the exquisite world of Ammara Khan's bridal couture dresses. From ravishing Pakistani bridal dresses to elegant bridal dresses for barat and mesmerizing bridal shower dresses, Ammara Khan has it all. Explore our collection and make your special day truly unforgettable.

    ReplyDelete