- Using Get Records to read records
- Using Get Records to read records
Get Records Element
With the Get Records element, we can get a single record or multiple records.With the new functionality in Flow, we no longer need to create a variable to store these record(s), this can now be automatically created for us.
Stepping through this configuration we have (1) select our object to get records from, (2) filter condition, in this example, we only want contacts where the accountID = the variable recordId (which is the Account record that started this flow), (3) we sort the contacts received by FirstName, (4) we get all records and (5) we let Salesforce create the record collection variable to store them for us.
Helpful Tip
While you can automatically store all fields (as we did above), there are some records that have a lot of fields and if you only need a few of those fields displayed, then select "Choose fields and let Salesforce do the rest". You may run into problems later in your flow (like I did) and have some very strange errors occur if you get all fields from a large object.
The default:Instead, select just the fields you need:
Exercise: Get Records
Build a Flow with the Get Records element
Using Get Records
For this exercise, you will get some contact records and use a loop to display the results.
Create a new Screen Flow.
Add a Get Records component.
Configure the Get Records component as follows: (you only want to display contacts that DO have an email address).
You will also sort them by Name:
Rather than getting all the contact fields, you will just get the Full Name, email and phone.
Next, add a Loop element so you can display the records:
In the middle of the loop add a new Screen element:
Configure a heading using the Display Text component:
Drag three (3) Section components to the canvas and configure as follows:
Use the Add Column button to add an extra column to each of the three components and they will each be set to Half Width.
Drag a Display Text component into each of the three sections on the left so you can add labels for the field names:
Drag another three Display Text components to the sections on the right to display those field values.
When configuring the resource for each of these, select it from the "Current Item from Loop Loop thru records"
and select the appropriate field from there.
The final result should look like this:
Save your flow:
Run your flow to see the results, click Next to go to the next record.
Not only have you created a Get Records flow but you have also used a simple loop.
Great work!
No comments:
Post a Comment