The first time I saw Fast Create I was quite confused. Is a Record Create slow? Well, it is actually slower if you want to create multiple records at once. A Fast Create really is more than just one element. This is because you must build records to put in a SObject Collection Variable that you will then insert with your Fast Create. If you’re new to this element, you’re probably wondering what the heck I am talking about. Lets go over our use-case and then we will make sense of this madness.
The business case for this example is that we want to find all of the Opportunity Line Items (OLI) on an Opportunity that was just marked as Won. We want to push all Line Items over as Assets on the Account associated to the Opportunity. You might be saying you can do that in a Record Create? Well, did you know Salesforce has a Limit of 50 DATA Elements in one Flow? That means, if you’ve got a sizable list of products on an Opportunity, a User might break your Flow! We can actually utilize Assignment Elements to create the records and pass them into our Fast Create. This means we would be using just one create, just like if you were doing a Data Import with Workbench or Dataloader. Pretty powerful, right? So lets get started!
If you have not yet read Fast Lookup and Loops, you might want to take a look at them. This post is focused on how we get our Fast Create to work, and not so much how we query or loop through the records. I will be showing the ‘finished’ Fast Lookup and Loop so that you have it as reference in terms of what Variables were used.
So, how do we add records into a SObject Collection Variable? This was one of the hardest parts for me to understand. It took a while before it clicked. Hopefully this will be basic enough that you’ll not have the same issues I had when building your first Fast Create. So lets get started by adding in our First Assignment Element into our Flow!
In our first Assignment Element we have created an SObject Variable (New_Asset), and we are assigning the fields in that variable values based on static values (AccountId associated to the Opportunity and a Status of Purchased), as well as dynamic values from the existing Opportunity Line Item that we found in our Fast Lookup and are Looping through (SObject Variable – Existing_OLI).
In our second Assignment Element we are adding the SObject Variable we just created to our new SObject Collection Variable that we are going to use in our Fast Create. If you’re used to doing data loads, think of this as adding a row to an excel sheet. Every time you are looping through an Opportunity Line Item record we are transforming the data (as you saw in the previous element) and adding it as a row in our collection of Assets for the Fast Create (as you see in this element).
Now we need to finish this by dragging out the Fast Create element (under the DATA section of the Palette).
Set your SObject Collection Variable to be the Variable in your Fast Create and you’re done! Take a look at what the finished Flow looks like:
RECAP: Fast Create elements let you create a batch of records in your Flow. I like to think of the process as adding rows to an Excel sheet. Every time I go through my Loop, I am adding an additional row to the Excel sheet. My columns are the what I set in the first Assignment element. This means if you want to include a field you must assign it. This ‘final’ Excel sheet will be what I am going to insert into Salesforce. So, a Fast Create is like doing an insert of records in Workbench or Dataloader.