> ## Documentation Index
> Fetch the complete documentation index at: https://docs.filefetch.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Builder (Simple Mode)

> Find files using visual filters - no SOQL knowledge required

## Overview

The Query Builder (Simple Mode) provides an intuitive, no-code way to find files in Salesforce. Use dropdown filters to build your query visually - FileFetch automatically generates the SOQL query for you.

<Note>
  Simple Mode is perfect for users who aren't familiar with SOQL or want a faster way to build common queries. For advanced queries, use [Power Mode](/power-mode).
</Note>

## Export Type Selection

Before querying, choose what type of files to export:

<Tabs>
  <Tab title="Files (ContentVersion)">
    **Modern Salesforce Files**

    Export files stored in Salesforce Files (the modern file storage system).

    * **Object**: ContentVersion
    * **Use For**: Files attached to records after Winter '12
    * **Features**: Version control, rich metadata, superior organization
    * **Common Use Cases**: Documents on Accounts, Cases, Opportunities, custom objects
  </Tab>

  <Tab title="Attachments">
    **Legacy Attachments**

    Export legacy attachments that haven't been migrated to Salesforce Files.

    * **Object**: Attachment
    * **Use For**: Old attachments created before Salesforce Files
    * **Features**: Simple attachment model, parent record relationships
    * **Common Use Cases**: Historic data, legacy records not yet migrated
  </Tab>
</Tabs>

<Info>
  The export type determines which Salesforce object is queried and which filters are available. You can switch between types at any time.
</Info>

## Quick Filters

Quick Filters provide the most common filtering options. These filters automatically update the generated SOQL query.

### Date Range Filter

Filter files by when they were created:

| Option           | Description                       | SOQL                           |
| ---------------- | --------------------------------- | ------------------------------ |
| **Any**          | No date filter (default)          | *(none)*                       |
| **Last 7 Days**  | Files created in the last week    | `CreatedDate = LAST_N_DAYS:7`  |
| **Last 30 Days** | Files created in the last month   | `CreatedDate = LAST_N_DAYS:30` |
| **Last 90 Days** | Files created in the last quarter | `CreatedDate = LAST_N_DAYS:90` |
| **This Year**    | Files created this calendar year  | `CreatedDate = THIS_YEAR`      |
| **Last Year**    | Files created last calendar year  | `CreatedDate = LAST_YEAR`      |

<Tip>
  Date filters use the `CreatedDate` field. To filter by modification date, use [Power Mode](/power-mode) with `LastModifiedDate`.
</Tip>

### File Type Filter

Filter by common file extensions:

| Option                   | Extensions                      | Example Files                     |
| ------------------------ | ------------------------------- | --------------------------------- |
| **Any**                  | All file types                  | All files                         |
| **PDFs**                 | `.pdf`                          | Reports, contracts, forms         |
| **Word Documents**       | `.doc`, `.docx`                 | Letters, proposals, documentation |
| **Excel Spreadsheets**   | `.xls`, `.xlsx`                 | Data sheets, financial reports    |
| **Images (PNG/JPG/GIF)** | `.png`, `.jpg`, `.jpeg`, `.gif` | Photos, screenshots, diagrams     |
| **PowerPoint**           | `.ppt`, `.pptx`                 | Presentations, slide decks        |

<Note>
  For **Files (ContentVersion)**, this filters the `FileExtension` field.

  For **Attachments**, this filters the `Name` field using pattern matching (e.g., `Name LIKE '%.pdf'`).
</Note>

### File Size Filter

Filter files by size:

| Option     | Size Range        | SOQL Condition                                       |
| ---------- | ----------------- | ---------------------------------------------------- |
| **Any**    | All sizes         | *(none)*                                             |
| **Small**  | Less than 1MB     | `ContentSize < 1048576`                              |
| **Medium** | 1MB to 10MB       | `ContentSize >= 1048576 AND ContentSize <= 10485760` |
| **Large**  | Greater than 10MB | `ContentSize > 10485760`                             |

<Info>
  * For **Files**, uses `ContentSize` field (bytes)
  * For **Attachments**, uses `BodyLength` field (bytes)
</Info>

### Related Object Filter

Filter files attached to specific Salesforce objects:

<Warning>
  **Important**: This filter works differently than the others!

  FileFetch uses a **two-query approach**:

  1. First, queries the selected object (e.g., Account) to get Record IDs
  2. Then, queries files linked to those records via ContentDocumentLink

  This ensures you only get files attached to the selected object type.
</Warning>

Available objects:

* **All Objects** - No filtering by parent object
* **Accounts** - Files on Account records
* **Contacts** - Files on Contact records
* **Opportunities** - Files on Opportunity records
* **Cases** - Files on Case records
* **Leads** - Files on Lead records

<Tip>
  To filter by custom objects or use additional criteria (e.g., "Accounts in California"), use [Power Mode](/power-mode).
</Tip>

## Advanced Filters

Click **Show More Filters** to access additional filtering options:

### Version Filter (Files Only)

Choose which file versions to include:

* **Latest Only** (default) - Only the most recent version of each file
  * Adds `IsLatest = true` to the query
  * Recommended for most exports
* **All Versions** - Include all historical versions
  * No version filter applied
  * Use when you need version history

<Note>
  This filter only applies to **Files (ContentVersion)**. Attachments don't have versions.
</Note>

### Title/Name Contains

Search for files with specific text in their name:

* **For Files**: Searches the `Title` field
* **For Attachments**: Searches the `Name` field
* **Matching**: Case-insensitive, partial match
* **SOQL**: `Title LIKE '%searchterm%'`

**Example**: Entering "invoice" will find:

* `Invoice_2024.pdf`
* `Customer Invoice - March.docx`
* `INVOICE-FINAL.xlsx`

### Result Limit

Control how many results to return:

| Limit    | Use Case                        |
| -------- | ------------------------------- |
| **50**   | Quick previews, testing queries |
| **100**  | Default for most queries        |
| **200**  | Moderate-sized exports          |
| **500**  | Large exports                   |
| **1000** | Maximum single query            |

<Warning>
  If you need more than 1000 files, consider:

  * Using more specific filters to narrow results
  * Running multiple queries with different date ranges
  * Using [CSV Import](/csv-import) if you have a list of file IDs
</Warning>

## Generated Query Preview

As you adjust filters, the **Generated Query** section shows the SOQL that will be executed:

```sql theme={null}
SELECT Id, Title, ContentDocumentId, FileExtension,
       ContentSize, CreatedDate, LastModifiedDate
FROM ContentVersion
WHERE IsLatest = true
  AND CreatedDate = LAST_N_DAYS:30
  AND FileExtension = 'pdf'
  AND ContentSize < 1048576
LIMIT 100
```

<Info>
  The preview is **read-only** in Simple Mode. To edit the query directly, switch to [Power Mode](/power-mode).
</Info>

## Running Your Query

<Steps>
  <Step title="Set Your Filters">
    Choose the filters that match the files you want to export
  </Step>

  <Step title="Review Generated Query">
    Check the query preview to ensure it matches your intent
  </Step>

  <Step title="Execute">
    Click **Run Query** or press `⌘/Ctrl + Enter`

    FileFetch will:

    1. Execute the SOQL query against Salesforce
    2. Retrieve matching file metadata
    3. Display results in the table below
  </Step>

  <Step title="Review Results">
    The results table shows:

    * File title/name
    * Extension
    * Size
    * Created date
    * Last modified date
    * Select checkboxes for export
  </Step>
</Steps>

## Example Queries

Here are common filter combinations:

<AccordionGroup>
  <Accordion title="All PDFs from the last 30 days">
    **Filters**:

    * Date Range: Last 30 Days
    * File Type: PDFs
    * File Size: Any
    * Related Object: All Objects

    **Use Case**: Recent contract documents, reports
  </Accordion>

  <Accordion title="Large images on Opportunities">
    **Filters**:

    * Date Range: Any
    * File Type: Images (PNG/JPG/GIF)
    * File Size: Large (>10MB)
    * Related Object: Opportunities

    **Use Case**: High-resolution product photos, diagrams
  </Accordion>

  <Accordion title="All Word documents this year">
    **Filters**:

    * Date Range: This Year
    * File Type: Word Documents
    * File Size: Any
    * Related Object: All Objects

    **Use Case**: Annual documentation export
  </Accordion>

  <Accordion title="Small files on Cases (last 90 days)">
    **Filters**:

    * Date Range: Last 90 Days
    * File Type: Any
    * File Size: Small (\<1MB)
    * Related Object: Cases

    **Use Case**: Customer support ticket attachments
  </Accordion>

  <Accordion title="Excel spreadsheets with 'Report' in the title">
    **Filters**:

    * Date Range: Any
    * File Type: Excel Spreadsheets
    * File Size: Any
    * Related Object: All Objects
    * **Advanced**: Title Contains: "Report"

    **Use Case**: Finding all reports across the org
  </Accordion>
</AccordionGroup>

## Switching to Power Mode

Need more control? Switch to Power Mode:

1. Toggle **Power Mode** switch in the query editor header
2. The visual filters will be replaced with a SOQL editor
3. Your generated query will be pre-filled
4. Edit the query directly with full SOQL syntax

<Warning>
  Switching to Power Mode **disables** the visual filters. You'll need to write SOQL manually. Switch back to Simple Mode to use filters again (this will reset your query).
</Warning>

## Tips & Best Practices

<CardGroup cols={2}>
  <Card title="Start Broad, Then Narrow" icon="funnel">
    Begin with loose filters, then add more constraints based on results
  </Card>

  <Card title="Use Date Filters First" icon="calendar">
    Date filtering is the fastest way to reduce result set size
  </Card>

  <Card title="Test in Sandbox" icon="flask">
    Try your queries in a Sandbox environment before Production
  </Card>

  <Card title="Monitor Result Count" icon="hashtag">
    If you hit the limit, add more specific filters
  </Card>
</CardGroup>

## Limitations

Simple Mode has some limitations compared to Power Mode:

| Feature                   | Simple Mode             | Power Mode           |
| ------------------------- | ----------------------- | -------------------- |
| **Visual Filters**        | ✅ Yes                   | ❌ No                 |
| **Custom SOQL**           | ❌ No                    | ✅ Yes                |
| **Field Selection**       | ❌ Fixed fields          | ✅ Choose any fields  |
| **Complex WHERE Clauses** | ❌ No                    | ✅ Yes (AND, OR, NOT) |
| **Subqueries**            | ❌ No                    | ✅ Yes                |
| **Custom Object Filters** | ❌ Limited to 5 standard | ✅ Any object         |
| **ORDER BY**              | ❌ No                    | ✅ Yes                |
| **GROUP BY**              | ❌ No                    | ✅ Yes                |

For advanced use cases, see [Power Mode](/power-mode).

## Next Steps

<CardGroup cols={2}>
  <Card title="Power Mode" icon="code" href="/power-mode">
    Write custom SOQL queries for advanced filtering
  </Card>

  <Card title="CSV Import" icon="file-csv" href="/csv-import">
    Upload a CSV with specific file IDs to export
  </Card>

  <Card title="Export Configuration" icon="gear" href="/export-config">
    Configure how files are organized and named
  </Card>

  <Card title="SOQL Examples" icon="book" href="/reference/soql-examples">
    Common query patterns and templates
  </Card>
</CardGroup>
