Templates / Sync Salesforce files to AWS S3 backups

Salesforce is a leading enterprise customer relationship management (CRM) application, based in the cloud. (updated: 1657714812036)
Amazon Web Services (AWS) Simple Storage Service (S3) (updated: 1657718049845)

Sync Salesforce files to AWS S3 backups

Intermediate
SalesforceAWS S3Sales

Overview

This workflow uses a scheduled trigger, which fires the workflow daily and copies any new or updated files from Salesforce, and stores them in AWS S3.

Connectors Used

The following connectors are used in this template. This is provided for reference only - although you may need to consult the Salesforce and S3 docs for authentication instructions:

End Result

The image below shows a synced file in S3 and Salesloft :

end-result-salesforce
end-result-s3

Prerequisites

This workflow assumes the following:

  • You have API credentials set up with Salesforce and AWS S3.

Getting Live

In order to configure this workflow for use:

Workflow Logic

The overall logic of the workflow is:

  • The workflow is triggered by a scheduled trigger that runs daily.

  • Based on the Last Run Date, the workflow gets the file versions from Salesforce.

  • Loops through the received file versions, downloads the Salesforce files and uploads it to the S3 bucket.

  • In the end, it sets the Last Run Date, which will be used as a reference for the next run.

complete-wf-1

Implementation notes

'Last Run Date' and 'Remove 7 Days'

The output from the Remove 7 Days step will only be used the first time this workflow runs.

On the first run, there will be no last run date in data storage, so we need to set a date in recent history to make the first check.

The Remove 7 Days step uses the Date time helpers Minus from date operation. It takes the workflow's execution start time ($.env.execution_start_time) and removes seven days from it.

If you wish to change how far back the first check goes, you can highlight the Remove 7 Days step, and in the properties panel to the right, change the number of 'Days' based on your requirements.

After the first run, the workflow will keep track of its previous run in the Set Last Run Date step and use this value every time the workflow runs henceforth.

remove-7-days

Get File Versions

This step using Salesforce Find records operation gets the Content Version of the files.

get-file-versions

The output for this step includes a list of files and their details that have been newly created or updated since the last run.

get-file-version-op

To ensure this, Salesforce uses a condition to check where the LastModifiedDate should be Greater than the Last Run Date ($.steps.storage-1.value).

get-file-versions-condition

These files are later one by one downloaded from Salesforce and uploaded to S3.

get-version-further-step

Step-by-step Explanation