0

I want to extract data from Salesforce from command line. I can use data loader by creating process-config file but I need to automate this process using windows batch file. For example, I have 5 different objects in SF from where I need to pull data regularly. The data pull from those 5 objects will always be from a several orgs (not a single org). Is there a way to extract data from salesforce for those 5 objects without having to create a map file. The reason for not creating map file is that the 5 objects may differ from org to org. Hard coding the SOQL will not work for my requirement. Any suggestions as to how I can achieve this in Salesforce?

2

I had a similar project for a client. I used DataLoader + Batch script file to automate extract / import data from/to Salesforce.

Look a this amazing tutorial to Setting up Automated DataLoader.

http://www.developerforce.com/media/Cheatsheet_Setting_Up_Automated_Data_Loader_9_0.pdf

At the end you'll be able to launch a script (.bat file). Then you can create a Scheduled Task on your server to automate all your processes.

I remember that i had to hard code my SOQL query in the process-conf.xml and my map files. I used Node.js to run some script to read/write DataLoader process-conf.xml file and to create some map file etc... (Another exemple : Creating log files...)

For your MAP FILES :

  • EXTRACT : It's not mandatory to use a map file (Your .csv header will be filed by your fields API's names)
  • IMPORT : If you specify field API NAME in the header of your .csv file, Salesforce will automatically map your fields with SalesForce.

I hope it will help you !

  • I only need to extract data from Salesforce, so not creating a map file is a great news. So as per the cheatsheet there will be a SOQL query in the process-conf.xml. For instance, I need to extract data from the Users (all fields) object in Salesforce. How can I extract data from a User object without writing a SOQL query with all the field names? Appreciate your help on this. – LearningMacro Nov 6 '17 at 16:22
  • As your know, you can't do a SELECT * FROM User... I think that the best way is to create a big SOQL with all your fields... Your fields will not change everyday. Or, if you can retrieve all the fields with SalesForce API you can create a script that create a SOQL query with all requested fields... As i said, i did it for a client. I created a Node.js script (but you can do it with other script languages) to create a SOQL query dynamically. I think this is the best way... :/ – FabienHuot Nov 6 '17 at 16:30
  • @FabienHuot- I am able to generate a csv using the cheat sheet and still not able to find a way to retrieve all fields for an object. Have the SOQL query in the process-conf.xml file. I haven't worked on node.js. Can you give some guidance around how to retrieve all fields via Node.js or any scripting language. Thanks. – LearningMacro Nov 6 '17 at 21:00
  • @LearningMacro I don't remember but you can use SalesForce API to retrieve a JSON file with all fields. (I used NodeJS but you can use other script languages) :) developer.salesforce.com/docs/atlas.en-us.api_rest.meta/… You can parse the JSON to retrieve all your Objects fields and then build a dynamic SOQL query I hope it will help you – FabienHuot Nov 8 '17 at 10:30
  • @LearningMacro any news ? :) – FabienHuot Nov 8 '17 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.