Loading
Salesforce now sends email only from verified domains. Read More
Help Agent Performance DegradationRead More
Automate Your Business Processes
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Creating Records with Required Field Validation Example

          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.

          1. 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.
          2. Create a screen flow.
            1. From the Automation app, click New. Search for and select the Screen Flow.
            2. 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.

          1. Add a Screen element.
            1. Click Add element plus icon, and select Screen.
          2. Configure the element.
            1. For Label, enter Collect Contact Information.
              The API Name autofills.
            2. For Description, enter Collects contact information for the contact to create.
          3. Add screen components for the required fields.
            1. 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.
            2. For the Last Name field, add a Text component, set Label to Last Name, API Name to Contact_Last_Name, and select Require.
            3. For the Email field, add an Email component, set Label to Email, API Name to Contact_Email, and set Required to True.
            4. 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.
            5. 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.
            6. Click Done.

          Create the Contact Record

          Now that you have the required information, it's time to create the contact.

          1. Add a Create Records element.
            1. Click Add element plus icon, and select Create Records.
          2. Configure the element.
            1. For Label, enter Create Contact.
            2. For API Name, accept the autofilled name: Create_Contact.
            3. For How to set record field values, select Manually.
            4. For Object, select Contact.
          3. Set field values.
            1. For the last name Value, select Collect Contact Information and then Last Name.
            2. Click + Add Field.
            3. For Field, search for and select First Name.
            4. For the first name Value, select Collect Contact Information, and then select First Name.
            5. Click + Add Field.
            6. For Field, search for and select Email.
            7. For the email Value, select Collect Contact Information | Contact_Email | Value.
            8. Click + Add Field.
            9. For Field, search for and select Mobile Phone.
            10. For the mobile phone Value, select Collect Contact Information | Contact_Phone | Value.
            11. Click + Add Field.
            12. For Field, search for and select Account ID.
            13. 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.

          1. To manage errors, on the Create Records element, click the three dots, and then click Add Fault Path.
          2. To show error information, add a Screen element in the fault path.
            1. For Label, enter Show Error Message.
            2. Accept the API name autofill.
          3. Add a Message component to the error page.
            1. In the Components list, click Message.
            2. For API Name, enter ErrorMessage.
            3. For the Message Type, select Critical
            4. For Message Content, select + New Resource.
            5. For Resource Type, select Text Template.
            6. For API Name, enter Fault_Message.
            7. 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.
            8. Click Done.
            9. .

              The fault path catches unexpected errors and tells the user what went wrong.

            10. Click Done.
          4. 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.
            1. After the Show Error Message screen element, click Add element plus icon, and click Connect to element.
            2. Click the first screen element.
          5. Save the flow.
            1. For Label, enter Create a Contact.
            2. Accept the autofilled API Name.
            3. 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.

          1. To confirm success, add a Screen element after the Create Records element, on the success path.
          2. Configure the screen.
            1. For Label, enter Show Success.
            2. Accept the API name autofill.
          3. Add a Display Text component to the page.
            1. In the Components list, click Display Text.
            2. For API Name, enter SuccessMessage.
            3. In the text box, enter Contact created successfully!
          4. Add a Message component to the page.
            1. In the Components list, click Message.
            2. For API Name, enter SuccessMessage.
            3. For the Message Type, select Success
            4. For Message Content, enter Contact created successfully!
            5. Click Done.

          Test the Flow

          Thoroughly test the flow before activating it.

          1. To start debugging, click Debug, and then click Run.
          2. To verify successful creation, enter sample data and verify that the flow creates the contact successfully.
          3. To verify field values, check that the created contact has all the expected field values.
          4. Test to confirm error handling adding a duplicate record.
          5. Remove the sample data before activating the flow.
           
          Loading
          Salesforce Help | Article