πŸ“ Salesforce to S3 file migration & cleanup

⚑ 150 views Β· πŸ“ File Management

Description

Salesforce to S3 File Migration & Cleanup

Automate archiving old Salesforce files to Amazon S3, log them back in Salesforce, and free up org storage β€” all from a scheduled n8n workflow.


πŸ”§ How It Works (High-Level)

  1. Schedule Trigger kicks off (e.g., daily).
  2. Query Salesforce for ContentDocument records older than 365 days.
  3. Loop Each File β†’ download binary via REST.
  4. Upload to S3 with the original filename.
  5. Lookup Links (ContentDocumentLink) to keep the parent record reference.
  6. Filter Out Users (ignore LinkedEntityId starting with 005).
  7. Create S3_File__c record in Salesforce for traceability.
  8. Delete Original File from Salesforce to reclaim storage.
  9. Notify via Slack when the batch is done.

Screenshot 20250723 135316.png

πŸš€ Set Up Steps (Time: ~45–90 mins)

  1. Import n8n Workflow JSON and wire up credentials (Salesforce OAuth2, AWS S3, Slack).
  2. Install Salesforce Unmanaged Package (Custom Object S3_File__c, Apex controller, LWC, settings).
  3. Fill S3Settings__c (bucket, region, keys, expiry) or swap to Named Credentials.
  4. Test with a Sandbox Batch (e.g., small date range) and verify upload/delete.
  5. Schedule & Monitor (tweak interval, Slack channel).

πŸ’– Why you’ll love it

πŸ“¦ What’s Included

All components are editable β€” extend, replace, or integrate with your own processes.


🧱 Requirements

πŸ”— Nodes Used

HTTP Request, Slack, AWS S3, Salesforce, Schedule Trigger

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup