How to use a Fast Delete

Have you ever had the need to delete a group of records all at once?  If you’re dealing with a sizable amount of records, you can’t get by using multiple Record Updates.  The easiest and most efficient way to do this is to use a Fast Delete.  A Fast Delete allows us to delete hundreds of records at once in one Flow!

Deleting data in Salesforce is something that we typically don’t want to do.  And, when we do, there needs to be a good reason why.  In most cases that I’ve used a Fast Delete it has been removing a relationship that was no longer desired (Assigned Permission Sets, Public Group Memberships, or Campaign Memberships).  The example we’ll go over removing Contacts from a Campaign when their Account is no longer listed as a current customer.  The reason is that our Marketing department uses this Campaign to send out alerts to all of our current customers, and we only want active customers to receive the Campaign’s emails.

The first thing we will want to do is navigate to the Campaign Member Fields (Setup | Customize | Campaigns | Campaign Members | Fields).  We will create a custom formula field that will grab the Contact’s AccountId for us so that we can reference it in our Flow when we query Campaign Members.

CampaignMemberAccountId

Now, we can get into our Flow to query all of the Campaign Members related to the Account that just got turned to be ‘former customer’.

If you have not yet read Fast Lookup, you might want to take a look it.  This post is focused on how we get our Fast Delete to work, and not so much how we query to find the records to delete.  I will be showing the ‘finished’ Fast Lookup so that you have it as reference in terms of what Variables were used.

Fast Lookup for Fast Delete

So, unlike in a Fast Update or Create, we have already queried all of the records that meet our criteria in one collection.  Typically you’ll want your Fast Delete to be simply the records that meet your criteria, because that is the most scalable solution if you’re dealing with a large number of records.

Now we need to finish this by dragging out the Fast Delete element (under the DATA section of the Palette).

Fast Delete

Set your SObject Collection Variable to be the Variable in your Fast Lookup and you’re done!

Fast Delete Element

Take a look at what the finished Flow looks like:

Completed Fast Delete Flow

To get this to run properly, we would now need to setup a Process Builder to pass in the Campaign Id and the Account Id that we reference in our Fast Lookup.  We would want our Process Builder to fire off of when the Account switches to former customer.

RECAP:  Fast Delete elements let you delete a batch of records in your Flow. While we don’t often use the delete ability in Salesforce, there are certain situations when we need to use it.  Keep in mind the Flow limits that we have when you’re figuring out how to get your collection for deletion.  So, a Fast Delete is like doing an delete of records in Workbench or Dataloader.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s