Thursday, February 16, 2017

How to include batch of test data in to Salesforce Dev accounts?

When you work with salesforce, you will need to have test data in salesforce dev account.

In WSO2 if you use salesforce connector, sometimes you will need to deal with queryMore function.
For more information, please check this link.

This is a sample on how to include test data in to Salesforce.

Salesforce it self provide an awesome tool called Data loader. You can go in to this document from this link.

Im going to use this in an open source /linux environment.

Pre Req : Need JDK 1.8

Step 1 : Install data loader.

1. Check out the code from git.  (https://github.com/forcedotcom/dataloader)
git clone https://github.com/forcedotcom/dataloader.git

2. Build it

mvn clean package -DskipTests
3. To run the data loader

java -jar target/dataloader-39.0-uber.jar

Step 2 : Login to Data loader

Provide your username (email address), password along with your security token and login url E.g., (https://login.salesforce.com/services/Soap/u/39.0) I have explained how to find your api login url in one of my previous blog post.





Step 3 : Create your test data.

Click on "Export" and Next and select the salesforce object (In Here I have selected Account) where you need to have test data.


Then select the fields from the check boxes and click on Finish.



Existing data will be exported in to a csv file.

Open the extract CSV in an excel sheet and create any number of test data for just by dragging the last cell. It will increment the data in each cell. Note : You should delete the existing data in the Account from CSV before you upload. So newly incremented data will be there.




Step 3 : Import test data in to Data Loader

Next step is just just click on the "Import" -> Select the salesforce object (in here it is Account) -> Click Next -> Click on Create or Edit a Map -> Map the attributes with the coulmns in CSV as below.



Click Next -> Finish. Select a file location to save error files.

Then it will insert the bulk data and you will receive it once it is finished and success. You can also view errors if exists.


Now if you query salesforce from developer console, you will be able to see your data.



That's it! :) Happy coding!





No comments:

Post a Comment