---
schema_version: "1"
id: eb5b8737e54dbf79d6dc8bb1c564177ab4a98091a5f4d6b688b85bb6c46f2329
title: Create Flow Element to Get Contact ID from Email Address
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-ae/loan-agent/guides/aes-create-flow-element-to-get-contact-id.md
canonical_url: https://developer.salesforce.com/docs/ai/loan-agent/guide/aes-create-flow-element-to-get-contact-id.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7562adde6bbf6e7294993439568af9256c23c1741008e65ce0f2a00d37b86ac4
products:
  - Loan Prequalification Agent
  - data-ae
---
# Create Flow Element to Get Contact ID from Email Address

A Flow Builder element represents an action that a flow can execute. Create an element to retrieve the Contact ID from the user’s email address, allowing the agent to surface relevant information.

## 1. Create the Element

1. On the flow you created in [Step 2 - Create Flow to Retrieve File ID](https://developer.salesforce.com/docs/ai/loan-agent/guide/aes-create-flow-to-retrieve-file-id.md), click the **+** button, search and select the **Get Records** element.
2. Configure the **Get Records** element:

   - **Label**: `Get Contact ID from Email Address`
   - **Get Records for This Object**:

     - Select **Salesforce Object** as **Data Source**.
     - For the **Object** field, search and select **Contact**.

3. Under **Filter Contact Records**, enter the condition values:

   - **Field**: Email
   - **Operator**: Equals
   - **Value**: +New Resource:
     - **Resource Type**: Variable
     - **API Name**: `contact_email`
     - **Data Type**: Text
     - Under **Availability Outside the Flow**, check the **Available for input** and **Available for output** checkboxes.
     - Click **Done**.

4. Under **Sort Contact Records**:

   - **Sort Order**: Descending
   - **Sort By**: `SystemModstamp`

5. Under **How to Store Record Data**:

   - Select **Choose fields and assign variables (advanced)**.
   - Under **Where to Store Field Values**, select **In separate variables**.

6. Under **Select Variables to Store Contact Fields**:
   - **Field**: ID
   - **Variable**: New Resource
     - **Resource Type**: Variable
     - **API Name**: `contact_ID`
     - **Data Type**: Text
     - Under **Availability Outside the Flow**, check the **Available for input** and **Available for output** checkboxes.
     - Click **Done**.
       ![Element 1](https://developer.salesforce.com/docs/media/loan-agent-step-2-1.png '{"class": "image-framed"}')

## 2. Save Flow Configuration

1. Click **Save** on the top right and enter values in the flow saving modal fields.
2. The flow saving modal opens. For **Flow Label** enter `Document ID from Email`.
3. Click **Show Advanced** to open advanced settings.
4. Under **How to Run the Flow**, select **System Context Without Sharing–Access All Data**.
5. Click **Save**.

## 3. Add a Fault Path

1. On the **Get Contact ID from Email** tile, click the 3-dot menu and select **Add Fault Path**.
2. After the **Fault** path, click the **+** to add an **Assignment** element.
3. Enter as **Label**: error_message (Text).
4. Under **Set Variable Values**:
   - **Variable**: Select **New Resource** and enter the details.
     - **Resource Type**: Variable
     - **API Name**: `error_message`
     - **Data Type**: Text
     - Click **Done**.
   - **Operator**: Select Equals.
   - **Value**: Select **Global Variables** > **Running Flow Interview** > **FaultMessage** (`$Flow.FaultMessage`).

![Flow Builder](https://developer.salesforce.com/docs/media/loan-agent-step-2-2.png '{"class": "image-framed"}')

### Next Step

- [Create Flow Element to Get Document ID from Contact ID](https://developer.salesforce.com/docs/ai/loan-agent/guide/aes-create-flow-element-to-get-document-id.md)
