So basically the requirement was to automatically download the file from a FTP/SFTP and upload the file in Salesforce Leads. To upload the file we will create a batch and schedule it using Window Scheduler.
To achieve this functionality in short we will create a batch to download the file from FTP/SFTP and save it in our local machine. And then upload it to salesforce Leads using CLI Data Loader.
Please follow below steps :
STEP : A
- Download & Install WinSCP on a window machine.
- Connect the FTP/SFTP using credentials.
- Go to session → Generate session URL/code.
- Check only User Name, Password & Initial directory in the case of FTP.
- In the case of SFTP check SSH host key checkbox also.
- Copy the generated url.
- Create a txt file using following code below :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Connect Open URL COPIED FROM STEP 5 # Change remote directory cd / # Download file to the local directory c:\ get fileName.csv c:\TestFolder\ # Disconnect Close |
- Save the txt file. My file name is example.txt
- Open CMD.
- Copy and paste following command :"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script=C:\TestFolder\example.txt
- Hit enter.
- The file will be copied from your FTP/SFTP to your window machine.
STEP : B
- First of all, make sure you have the Admin rights on the machine.
- Then, download the data loader setup file on the machine by going into Salesforce environment Setup –> Data Management –> Data Loader. Choose the option “Download Data Loader for Windows“. It will download the latest version of data loader setup file. Install it by following the setup wizard.
- Also, you need to have the required version of JRE (Java Run Time Environment).
- Download the latest JRE version from Oracle site downloads page.
- Install the downloaded JRE file.
- Please follow steps 1 to 5 from this link below : https://developer.salesforce.com/docs/atlas.en-us.dataLoader.meta/dataLoader/command_line_intro.htm
STEP : C
- Create batch file of commands.
- Schedule the task in window scheduler, follow the steps here https://www.thewindowsclub.com/how-to-schedule-batch-file-run-automatically-windows-7
Schedule the batch classes and you are good to go.
If you have any question please leave a comment below.
If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !
Thanks
Keep Coding
0 Comments