Archive Salesforce contacts and leads from Snowflake

Recipe ToolsDatabaseMarketingCRMData ParserUtilitiesProductivitySales EnablementDeveloper Tool

What it does

When someone calls this automation, it queries Snowflake for contacts and leads marked do-not-sync. It then removes those records from Salesforce in batches and archives them to Amazon S3 so the team has a backup before deletion.

Who it's for

Data and analytics teams who need to remove Salesforce contacts and leads based on Snowflake sync rules while keeping an audit trail.

How teams use this

Remove do-not-sync records automatically

Run the purge on a schedule so contacts and leads marked in Snowflake are deleted from Salesforce without manual intervention. The team stays in sync across systems.

Purge records for compliance

Delete Salesforce contacts and leads when someone requests removal, using Snowflake as the source of truth. This keeps both systems compliant with data retention policies.

Filter records by date range

Only delete contacts and leads that were marked do-not-sync before a specific date, so recent records are preserved. Add a date condition to the Snowflake query.

Notify multiple teams of purge results

Send the completion notice to Slack and email so both operations and data teams see which contacts and leads were archived and deleted. Include the S3 backup link.

How it works

  1. Start the purge process. A function call initiates the automation to query Snowflake and delete Salesforce records marked for removal.
  2. Find contacts and leads to delete. Query the Snowflake V_MARKETO_CONTACT_LEAD_DO_NOT_SYNC table to identify all contacts and leads that should be removed from Salesforce based on sync rules.
  3. Archive records before deletion. Store the identified contacts and leads in Amazon S3 as a backup file so the team can audit what was purged from Salesforce.
  4. Delete records in batches. Remove the archived contacts and leads from Salesforce in batches to ensure efficient processing and avoid system limits.
  5. Send completion notice. Email the team with a summary of archived and deleted contacts and leads so everyone knows the purge operation finished successfully.