---
schema_version: "1"
id: 12f606f855554820c0e979fa9c1e9ede32b3b191c2dd58065630b8c0551dada0
title: Create Flow Element to Get Document ID from Contact ID
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-document-id.md
canonical_url: https://developer.salesforce.com/docs/ai/loan-agent/guide/aes-create-flow-element-to-get-document-id.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2637c2e5ee5a95f3ac3a746db8f721e7fcc2b57de8aff0071b44dbfaf7683a68
products:
  - Loan Prequalification Agent
  - data-ae
---
# Create Flow Element to Get Document ID from Contact ID

Create a second element to retrieve the Document ID from the user’s Contact ID, allowing the agent to surface relevant information.

## 1. Create the Element

1. In the **Flow Builder**, under **Get Contact ID from Email Address**, click the **+** button, and search for the **Get Records** element.
2. The **Get Records** modal opens. Enter as **Label**: Get Document ID from Contact ID.
3. Under **Get Records for This Object**:

   - Select Salesforce Object as **Data Source**.
   - For **Object** field, search and enter **Content Document Link**.

4. Under **Filter Content Document Link Records**:

   - **Field**: Linked Entity ID
   - **Operator**: Equals
   - **Value**: contact_ID (created on the previous step [Create Flow Element to Get Contact ID from Email Address](https://developer.salesforce.com/docs/ai/loan-agent/guide/aes-create-flow-element-to-get-contact-id.md))

5. Under **Sort Content Document Link Records**:

   - **Sort Order**: Descending
   - **Sort By**: `SystemModstamp`

6. Under **How to Store Record Data**:

   - Select **Choose fields and assign variables (advanced)**.
   - Under **Where to Store Field Values**, select **In separate variables**.

7. Under **Select Variables to Store Content Document Link Fields**:

   - **Field**: Enter `ContentDocumentId`
   - **Variable**: Select New Resource and enter the details.
     - **Resource Type**: Variable
     - **API Name**: content_document_ID
     - **Data Type**: Text
     - Under **Availability Outside the Flow**, check the checkboxes next to **Available for input** and **Available for output**.
     - Click **Done**.

## 2. Save Flow Configuration

1.  Click **Save** on the top right and enter values in the flow saving modal fields.
2.  For **Flow Label**, enter **Document ID from Contact ID**.
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 Fault Path

1. On the **Get Contact ID from Contact ID** tile, click the 3-dot menu and select **Add Fault Path**.
2. After the **Fault** path, add an **Assignment** element.
3. Enter as **Label**: error_message (Text).
4. Under **Set Variable Values**:

   - **Variable**: Select **New Resource**

     - **Resource Type**: Variable
     - **API Name**: error_message
     - **Data Type**: Text
     - Click **Done**.

   - **Operator**: Equals
   - **Value**: Select **Global Variables** > **Running Flow Interview** > **FaultMessage** (`$Flow.FaultMessage`).

## 4. Save the Flow

1. Click **Save**.
2. Click **Activate**.

![Element 2](https://developer.salesforce.com/docs/media/loan-agent-element-2.png '{"class": "image-framed"}')

### Next Step

[Finalize Flow Retrieving File ID from Email Address](https://developer.salesforce.com/docs/ai/loan-agent/guide/aes-finalize-flow-retrieving-file-id.md)
