Many times we were asked from various social media platform including Linkedin, Twitter, Pinterest but not limited to tech forums like Salesforce Stack Exchange, Stack Overflow for a Salesforce app to download attachments. I remember one question from a user where he posted asking: “Is there a possibility of getting associated attachments of opportunities, quotes to other teams that are outside Salesforce?” In other words, for the teams who are not the users of Salesforce, but are working for the same company.
The answer is yes. Recently DBSync has released an app which, when installed on a specific user instance of Salesforce, can download the attachment of any standard or custom object of Salesforce to a designated folder of FTP or SFTP or FTPS server.
In this article, I would be demonstrating how to download the file to a designated file path of an FTP server using DBSync Salesforce package for downloading attachments. To do so, you must have the latest package of the app installed on your Salesforce instance and follow these three steps.
Step 1: Add a Connector tab within Salesforce
Once after you login to your Salesforce Instance, you should click on the “All Tabs” icon located on the Menu Bar, which will open the below screen. Follow the below listed steps to add the Connectors Tab to your view in Salesforce. By doing so will ensure quick access of the configuration screen for FTP connector from Salesforce menu.
- Click on “Customize My Tabs” button located on top right corner of the All Tabs page.
- Choose the App from the Custom App drop down to add to the selected app.
- From the Available Tabs combo box , select the Connector Tab and Click Add as shown in the image #1.
- This action will move the Connectors to Selected Tabs combo box
- Now Hit the “Save” button that will show up connector tab on the Menu of your Salesforce instance.
Step 2: Setup the FTP connection parameters from DBSync Connector tab
The Connectors tab is the functionality from where you can set up your desired FTP \ SFTP \ FTPS connection so that the attachments get downloaded. To set up the FTP parameters, click on Connectors tab will open up the FTP\FTPS connector settings page as shown in the following image #2.
- Click on > Icon adjacent to FTP label from Connector combo box, which will show up it’s connection parameters.
- Click on the Edit button from the FTP Connection combo box as shown in the image i.e. on the right hand section which will make the fields editable.
- Now Input Field FTP Host, FTP Port, FTP Username , FTP Password which are indicated by red * (Mandatory fields to save the connection parameters) and hit Save to save the connection parameters.
- If you would like to change the FTP to FTPS, you can do so by choosing the FTPS value from the field “FTP Type” and Save the connection parameters.
Similarly, you can connect to any FTPS or SFTP host server so as to download the attachments directly to the saved host from the connectors screen of the package.
Step 3: Direct API
Alternatively if you want to use the API method to access the file, and download it to the designated FTP server, you can use this sftofilesytem API call to connect with an Salesforce instance and an FTP server, and pass a query to download the file. Try the API using the following link: http://api.mydbsync.com/api/api-docs/v1/sftofilesystem
The below is the sample call from the endpoint. This would make the API call more predictable for the reader.
curl -X POST –header ‘Content-Type: application/json’ –header ‘Accept: text/html’ -d ‘
“queryToTheAttachment”:”select Name,Body from attachment where id = ’00P2800000lT3mq”
As explained in this article, I have saved the connection parameters to an FTP server containing the ip 184.108.40.2062 so whenever a file is attached in the Salesforce, the same file gets downloaded to the FTP host. Upon which any team outside Salesforce can access the file just by logging to FTP server. Moreover, you also have the ability to define the directory structures and pass them from FTP File Location for all the files to download to defined path.