You are here:
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.
Required Editions
| View supported editions. |
| User Permissions Needed | |
|---|---|
| To open, edit, create, activate or deactivate a flow using all flow types, elements, and features available in Flow Builder, including Einstein and Agentforce for Flow: | Manage Flow |
This example shows how to build a screen flow that creates contact records and populates all required fields. Identify required fields, collect the necessary data from users, and manage errors effectively.
Scenario
Build a screen flow that sales representatives use to create contacts quickly during prospect meetings. The flow:
- Collects all required information from the user
- Creates a contact record without errors
- Addresses cases where users leave fields blank
- Provides helpful error messages when record creation fails
For this example, use these fields as the required set:
- Last Name (standard required field)
- Email (required by organization validation rule)
- Account (required for business contacts by record type)
Key Takeaways
- Always identify required fields before building flows that create records.
- Mark required fields as required on-screen components to prevent users from skipping them.
- Add fault paths to Data Manipulation Language (DML) operations to manage unexpected errors effectively.
- Use decision elements for complex validation logic.
- Test flows with various data scenarios, including edge cases.
- Consider using Quick Actions when you want Flow Builder to indicate required fields automatically.
- Document your flows with descriptions that list the required fields and why.
High Level Steps
Review the steps of this example. Follow them in order or navigate to a section for more specific instructions.
- Create the Flow
Create the flow that collects contact information and creates a contact. - Build the Data Collection Page
Create a page that collects all required contact information from users. - Create the Contact Record
Now that you have the required information, it's time to create the contact. - Add a Fault Path for Error Management
Configure the Create Records element to manage errors effectively. - Add a Success Screen
Create a page that shows after successful record creation. - Test the Flow
Thoroughly test the flow before activating it.
See Also
Create the Flow
Create the flow that collects contact information and creates a contact.
-
Open the Flows list view.
- From Setup, in the Quick Find box, enter Flows, and then select Flows.
- From the Automation app, select the Flows tab.
- From the Flows tab in any Lightning app, click the actions menu and select Open Flow.
-
Create a screen flow.
- From the Automation app, click New. Search for and select the Screen Flow.
- From Setup, click New Flow. Search for and select Screen Flow.
Build the Data Collection Page
Create a page that collects all required contact information from users.
-
Add a Screen element.
-
Click
, and select Screen.
-
Click
-
Configure the element.
-
For Label, enter Collect Contact Information.
The API Name autofills.
- For Description, enter Collects contact information for the contact to create.
-
For Label, enter Collect Contact Information.
-
Add screen components for the required fields.
-
For the First Name field, add a Text component, set Label to
First Name, API Name to
Contact_First_Name, and leave Require unselected.
First Name is optional for contacts.
- For the Last Name field, add a Text component, set Label to Last Name, API Name to Contact_Last_Name, and select Require.
- For the Email field, add an Email component, set Label to Email, API Name to Contact_Email, and set Required to True.
- For the Account field, add a Lookup component, set API Name to Related_Account, Field API Name to AccountId, Label to Account, Object API Name to Contact, and set Required to True.
- For the Phone field, add a Phone component, set API Name to Contact_Phone, Label to Phone, and set Required to False, so it shows as an optional field.
- Click Done.
-
For the First Name field, add a Text component, set Label to
First Name, API Name to
Contact_First_Name, and leave Require unselected.
Create the Contact Record
Now that you have the required information, it's time to create the contact.
-
Add a Create Records element.
-
Click
, and select Create Records.
-
Click
-
Configure the element.
- For Label, enter Create Contact.
- For API Name, accept the autofilled name: Create_Contact.
- For How to set record field values, select Manually.
- For Object, select Contact.
-
Set field values.
- For the last name Value, select Collect Contact Information and then Last Name.
- Click + Add Field.
- For Field, search for and select First Name.
- For the first name Value, select Collect Contact Information, and then select First Name.
- Click + Add Field.
- For Field, search for and select Email.
- For the email Value, select Collect Contact Information | Contact_Email | Value.
- Click + Add Field.
- For Field, search for and select Mobile Phone.
- For the mobile phone Value, select Collect Contact Information | Contact_Phone | Value.
- Click + Add Field.
- For Field, search for and select Account ID.
- For the Account ID value, select Collect Contact Information | Account | Record ID.
Add a Fault Path for Error Management
Configure the Create Records element to manage errors effectively.
- To manage errors, on the Create Records element, click the three dots, and then click Add Fault Path.
-
To show error information, add a Screen element in the fault path.
- For Label, enter Show Error Message.
- Accept the API name autofill.
-
Add a Message component to the error page.
- In the Components list, click Message.
- For API Name, enter ErrorMessage.
- For the Message Type, select Critical
- For Message Content, select + New Resource.
- For Resource Type, select Text Template.
- For API Name, enter Fault_Message.
- For Body, enter We couldn't create the contact due to an error: , and then in the Insert a resource field, select Running Flow Interview, and then select Fault Message.
- Click Done.
-
.
The fault path catches unexpected errors and tells the user what went wrong.
- Click Done.
-
Add a connector to the first element.
If the user can fix the error, the connector brings them back so they can change their inputs.
-
After the Show Error Message screen element, click
, and click Connect to element.
- Click the first screen element.
-
After the Show Error Message screen element, click
-
Save the flow.
- For Label, enter Create a Contact.
- Accept the autofilled API Name.
- For Decription, enter Creates a contact by using information collected in a screen. If there's an error creating the contact, the user is directed to the first screen to try again.
Add a Success Screen
Create a page that shows after successful record creation.
- To confirm success, add a Screen element after the Create Records element, on the success path.
-
Configure the screen.
- For Label, enter Show Success.
- Accept the API name autofill.
-
Add a Display Text component to the page.
- In the Components list, click Display Text.
- For API Name, enter SuccessMessage.
- In the text box, enter Contact created successfully!
-
Add a Message component to the page.
- In the Components list, click Message.
- For API Name, enter SuccessMessage.
- For the Message Type, select Success
- For Message Content, enter Contact created successfully!
- Click Done.
Test the Flow
Thoroughly test the flow before activating it.
- To start debugging, click Debug, and then click Run.
- To verify successful creation, enter sample data and verify that the flow creates the contact successfully.
- To verify field values, check that the created contact has all the expected field values.
- Test to confirm error handling adding a duplicate record.
- Remove the sample data before activating the flow.

