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

# Microsoft 365 / Dataverse (Beta)

> Connect HelloLeo to Microsoft Dataverse (Power Platform / Dynamics 365)

<Warning>
  This integration is currently in **beta**. Some features are still in development. See the [Current Limitations](#current-limitations) section below.
</Warning>

Connect HelloLeo to Microsoft Dataverse to build web applications on top of your Power Platform or Dynamics 365 data.

## What is Dataverse?

Microsoft Dataverse is the data platform behind Power Platform (Power Apps, Power Automate) and Dynamics 365. It provides:

* **Structured data storage** with tables, columns, and relationships
* **Built-in security** with row-level and field-level permissions
* **Business logic** with workflows, business rules, and plugins
* **Standard entities** like Accounts, Contacts, Leads, Opportunities

With HelloLeo, you can build custom web frontends that read and write directly to your Dataverse tables.

## Use Cases

* **Customer portals** - Let customers view their accounts, orders, and support tickets
* **Internal dashboards** - Visualize CRM data for sales teams
* **Data entry apps** - Simplified forms for field workers
* **Custom views** - Alternative interfaces to Power Apps

## Quickstart

<Steps>
  <Step title="Connect your Microsoft 365">
    Click **Microsoft 365** in Project Settings → Integrations and sign in with your Microsoft account.
  </Step>

  <Step title="Select your environment">
    Choose the Dataverse environment you want to connect to (e.g., your production or development environment).
  </Step>

  <Step title="Let Leo explore your data">
    Ask Leo: *"List the tables in my Dataverse and show me the schema of the accounts table."*
  </Step>

  <Step title="Build your frontend">
    Describe what you want: *"Create a dashboard showing all active accounts with their contact information."*
  </Step>
</Steps>

## Setup

1. Go to **Project Settings** → **Project Integrations**
2. Click **Microsoft 365**
3. Click **Connect with Microsoft** - you'll be redirected to Microsoft's login page
4. Sign in with an account that has access to your Dataverse environment
5. Grant the requested permissions
6. Back in HelloLeo, select your **Dataverse environment** from the dropdown
7. Start using Dataverse in your prompts

### Required Permissions

The Microsoft account you use must have:

* Access to the Dataverse environment
* Read permissions on the tables you want to query
* Write permissions on the tables you want to modify

## How It Works

HelloLeo uses the Dataverse Web API (OData) to interact with your data. When you connect:

1. **OAuth Authentication** - You sign in with Microsoft and grant HelloLeo access
2. **Environment Selection** - You choose which Dataverse environment to use
3. **Token Management** - HelloLeo securely stores and refreshes your access tokens
4. **API Calls** - All requests go through the HelloLeo Middleware to keep tokens secure

## HelloLeo Middleware

All Dataverse API calls from your generated frontend go through the HelloLeo Middleware, providing:

* **No CORS Issues** - Works immediately without configuration
* **Secure Tokens** - Your access tokens are never exposed to the frontend
* **Automatic Refresh** - Tokens are automatically refreshed when they expire
* **Request Logging** - All API calls are visible in the Network Monitor for debugging

## MCP Operations

Leo can use these commands to explore and modify your Dataverse:

### Data Operations

| Command             | Description                           |
| ------------------- | ------------------------------------- |
| `list_environments` | List available Dataverse environments |
| `list_tables`       | List tables in your environment       |
| `get_table_schema`  | Get columns and schema of a table     |
| `query_records`     | Query records with OData filters      |
| `get_record`        | Get a single record by ID             |
| `create_record`     | Create a new record                   |
| `update_record`     | Update an existing record             |
| `delete_record`     | Delete a record                       |

### Schema Operations

| Command         | Description                        |
| --------------- | ---------------------------------- |
| `create_table`  | Create a new custom table          |
| `add_column`    | Add a column to a table            |
| `delete_table`  | Delete a table (use with caution!) |
| `delete_column` | Delete a column from a table       |

## Example Prompts

### Explore your data

```
List all custom tables in my Dataverse and show me the schema
of the accounts table.
```

### Build a dashboard

```
Create a dashboard showing all active accounts from Dataverse.
Display name, industry, and annual revenue. Add a search filter
by company name.
```

### Create a form

```
Build a form to create new contacts in Dataverse. Include fields
for first name, last name, email, and phone. Link the contact to
an existing account using a dropdown.
```

### Query with filters

```
Show all opportunities from Dataverse where the estimated value
is greater than $10,000 and the status is "Open". Sort by
estimated close date.
```

## OData Query Support

The integration supports standard OData query parameters:

| Parameter  | Description                    | Example              |
| ---------- | ------------------------------ | -------------------- |
| `$select`  | Choose which columns to return | `name,accountnumber` |
| `$filter`  | Filter records                 | `statecode eq 0`     |
| `$orderby` | Sort results                   | `createdon desc`     |
| `$top`     | Limit number of records        | `50`                 |
| `$skip`    | Skip records (pagination)      | `100`                |
| `$expand`  | Include related records        | `primarycontactid`   |

### Filter Examples

```javascript theme={null}
// Active records
"statecode eq 0"

// Text contains
"contains(name, 'Contoso')"

// Date comparison
"createdon ge 2024-01-01"

// Multiple conditions
"statecode eq 0 and revenue gt 10000"

// Lookup field (note the underscore prefix and _value suffix)
"_primarycontactid_value eq 00000000-0000-0000-0000-000000000001"
```

## Current Limitations

<Warning>
  **Beta Limitations** - These features are not yet available but are planned:
</Warning>

### What Works Now

<Check>OAuth connection with Microsoft</Check>
<Check>Environment selection</Check>
<Check>Read data from any Dataverse table</Check>
<Check>Write data (create, update, delete records)</Check>
<Check>Schema exploration (list tables, get columns)</Check>
<Check>Create custom tables and columns</Check>
<Check>OData queries with filters, sorting, pagination</Check>
<Check>Network Monitor debugging</Check>

### Coming Soon

<Info>
  **End-User Authentication (RBAC)** - Currently, all API calls use the credentials of the person who connected the integration in HelloLeo. This means:

  * All users of your app have the same permissions
  * Dataverse's row-level security is not applied per user
  * You cannot build apps where different users see different data based on their Dataverse permissions

  **Workaround**: For now, you can build apps where all users have the same access level, or implement your own permission logic in the frontend.

  **Planned**: We're working on supporting end-user OAuth login, so each user authenticates with their own Microsoft account and sees only data they have access to in Dataverse.
</Info>

## Troubleshooting

### Connection Errors

#### "Token expired or invalid"

* Go to Project Settings → Integrations → Microsoft 365
* Click "Reconnect" to refresh your authentication

#### "Environment not found"

* Make sure you selected an environment after connecting
* Check that your Microsoft account has access to the environment

#### "403 Forbidden"

* Your account doesn't have permission to access this table or record
* Check your Dataverse security roles

#### "404 Not Found"

* The table or record doesn't exist
* Check you're using the correct entity set name (plural form, e.g., `accounts` not `account`)

### Data Not Showing

* **Check table name**: Use the plural entity set name (e.g., `accounts`, `contacts`, `opportunities`)
* **Check permissions**: Ensure your account can read the table in Dataverse
* **Use Network Monitor**: Click the API call to see the full request and response

### Getting Help

1. Use the **Network Monitor** to see API calls and errors
2. Ask Leo: *"The Dataverse call failed, can you check what went wrong?"*
3. Check your Dataverse security roles in the Power Platform admin center
4. Reach out to HelloLeo support on Discord

<CardGroup cols={2}>
  <Card title="Working with Integrations" icon="plug" href="/integrations/working-with-integrations">
    Learn how to use integrations effectively
  </Card>

  <Card title="Network Monitor" icon="activity" href="/features/network-monitor">
    Debug Dataverse API calls
  </Card>
</CardGroup>
