The post will focus on updating records. Updating records in Process Builder comes in two forms. Huh? Yes, it's true. Process Builder prompts you to select the record that started the processes or to select a related record. See the image below.
Lightning Flow is mostly the same. I'll combine both types into this single blog post but you'll see I have separated the cheatsheets and video into two. Let's get into the easier one first.
When updating a record in Process Builder, we have an assignment screen where we choose a field and the value we want to set that field to. It looks like the image to the left. It's a pretty simple and easy process.
Take note that I called this an assignment. I did that on purpose because in Lightning Flow, Assignment is the name of the element you'll choose when updating the record that triggered the Flow.
The Flow Assignment screen has all the same features of Process Builder. The names have been changed but they're basically the same. In Process Builder, you had to name your Action and in Flow that name is called a Label. A Field is called a Variable.
Why do they call it a variable? That sounds like a term for programmers. Don't let it freak you out. It's simply a placeholder to store something. Think of it as a drawer in your dresser that you put something in. When you need to use it, you simply go get it out of the drawer.
Now here is where Flow gets really cool. Flow has predefined boxes that have helpful stuff already prepared for you. They call these Global Variables and they all start with a $ sign. I don't know why but one of the most important Global Variables in a Record Triggered Flow is called $Record.
$Record is your friend! You heard it here first and it represents the record that triggered the flow. This is an important concept so don't forget about $Record.
In Process Builder, you choose your Field from the picklist. In Flow, you choose your Variable from a picklist however, your field is listed within the $Record Global Variable. First, select $Record, then the list of fields will appear for you to choose.
Remember our first lesson in this series when we talked about Before and After Record-Triggered Flows? If not, go back and review the Getting Started post. We learned that when we're working with the record that started the Flow, we almost always use a Before Record-Triggered Flow. That is what you will want to use for this first type of updating records.
Ready to move on to Updating other records?
When updating related records, you'll want to use the After Record-Triggered Flow. Salesforce makes this a bit obvious because the Update Records is not visible in the Before. So why can't we just use the Assignment as we did in the Before? Great question and here's why. In the Before Trigger, the record hasn't yet been saved to the object, as shown in the Order of Execution. It will be saved automatically so we don't have to do it. However, that is not true of the After Trigger so, we have to explicitly update our changes.
Process Builder really makes updating related records very simple. As shown in the image to the left, you select the radio box for related records and select the Object. Define your field values and you're done. However, because it's so simple, it's also limited to directly related records.
Lightning Flow gives us more power to determine what records we want to update. That power means the Update Record screen is a little more involved so let's walk step by step through it:
The first is to simply to select the Update Record element, give it a name, and select Specify conditions to identify records
A more advanced option, for updating records, is to use Use the IDs and all field values from a record or record collection (B).
I won't go too deep here but in Flow there are variables; a placeholder to hold stuff. That "stuff" might be defined as a record and record collection. Let's go back to our dresser and drawers analogy. If the drawer represents a field, say an Account Name, the dresser would represent a record object, the Account. If you have multiple dressers, more than one Account record, then it could be called a record collection.
To Use the IDs and all field values from a record or record collection, you first have to either define a Record variable or use the Get Record element to create one. We'll talk about the Get Record element next week so come back for more. The idea here is that you have a defined record or record collection and you want to update those records using that defined variable. Again, this option is more advanced and probably worthy of its own post.
That's a wrap for covering the basics of updating records. That was a lot to take in so watch the videos so you can see how it's done and download the cheatsheets for the highlights.
As always, if you have questions, you're welcome to reach out. I'll do my best to respond. To all the Flownatic experts out there, I welcome your feedback. Correct my oversites or add clarity where needed. Remember to subscribe to this blog site as well as to my YouTube channel. I look forward to continuing to grow together.