You are here:
Working with Data in a Flow
The real power of a flow is that it can automate updates to your data, whether the data lives inside your Salesforce org or in an external database. In a flow, you can look up values from records, connect to external systems, create records, update records, and delete records.
Required Editions
| View supported editions. |
Where to Start
Work through these topics to build a solid foundation for data operations in flows, or jump to the stage that matches what you're building.
| Stage | Topic | What You Learn |
|---|---|---|
| 1. Create Records | Creating a Salesforce Record from a Flow | Choose between the Create Records element and a Quick Action element of type Create. Understand how they differ in field availability, required field indicators, and whether the created record's ID is stored for later use. |
| 2. Validate Required Fields | Creating Records with Required Field Validation Example | Follow a complete example of a screen flow that identifies required fields, collects them from users, and handles errors so that records are created without REQUIRED_FIELD_MISSING failures. |
| 3. Update Records | Update Salesforce Records from a Flow | Update one record or many. Compare the two Update Records element options and Quick Action to choose the right approach based on how your flow identifies records and supplies new field values. |
| 4. Clone Records | Clone Records with a Create Records Element | Use a parent-child flow pattern to duplicate a record along with all of its field values, including fields that a standard Get Records element wouldn't retain. |
| 5. Get Related Records | Get Related Salesforce Records from a Flow (Beta) | Retrieve a parent record and its related child records in a single Get Records element, instead of chaining multiple elements together. |
| 6. Aggregate Collections | Sum or Count Items in Collections with the Transform Element | Use the Transform element to calculate a total or count from a collection's field values, and assign the result to a target variable—no custom code required. |
| 7. Join Collections | Join Collections in a Flow | Combine two related source collections into one target collection using join keys in the Transform element, for example to merge order data from an external system with Salesforce records. |
| 8. Optimize for Scale | Bulkified Record Processing to Avoid CPU Limits Example | See a before-and-after comparison that shows why performing DML inside a loop causes APEX_CPU_TIME_LIMIT_EXCEEDED errors, and how to refactor the flow to collect records during the loop and perform a single DML operation after it completes. |
IN THIS SECTION
- Creating a Salesforce Record from a Flow
To create a Salesforce record, use the Create Records element. You can also use a Quick Action element of type Create, but it has limited functionality. - Identify Required Fields
Before building a flow, identify the required fields for the object's records. There are two options: use Schema Builder or create a record on the object, but don't save it. Either option shows the required fields, but Schema Builder also shows system populated fields that you don't include in a flow. - Creating Records with Required Field Validation Example
Build a screen flow that captures all required fields and creates records without REQUIRED_FIELD_MISSING errors. This example demonstrates techniques for identifying required fields and managing errors in flows. - Avoid Overwriting Required Fields When a Screen Flow Updates a Record
When your screen flow collects field values and updates an existing record, prevent blank screen input from overwriting required fields and causing REQUIRED_FIELD_MISSING errors. - Bulkified Record Processing to Avoid CPU Limits Example
Learn how to refactor flows to use bulkification patterns that prevent APEX_CPU_TIME_LIMIT_EXCEEDED errors. This example demonstrates the difference between inefficient and optimized flow design. - Clone Records with a Create Records Element
Use a parent flow and a child flow to clone a record and all of its values. - Update Salesforce Records from a Flow
To update field values on existing Salesforce records, use either the Update Records element or a Quick Action core action. The right element depends on what the rest of your flow is doing. - Sum or Count Items in Collections with the Transform Element
Aggregate data from a source collection to calculate the sum or count of items in that collection, and assign the result to a target data field. - Join Collections in a Flow
Combine source collections from related flow resources into one target collection. - Get Related Salesforce Records from a Flow (Beta)
Access related records in complex data relationships.. Related records in the Get Records element are available in autolaunched flows.
Did this article solve your issue?
Let us know so we can improve!
