A Power Apps Code App (React + TypeScript + Vite) that fetches data from a different Power Platform environment using the Microsoft Dataverse connector's "List rows from selected environment" action.
This proof-of-concept demonstrates how a Code App running in one Dataverse environment can query tables in a separate target environment — useful for cross-environment reporting, data comparison, or migration scenarios.
- On launch, the app calls
GetOrganizations(from the same Dataverse connector) to auto-populate a dropdown with all environments the current user has access to. - The user selects a target environment from the dropdown (or edits the URL manually in the textbox below).
- The user enters a table logical name (e.g.,
accounts). - The app calls
ListRecordsWithOrganizationto fetch rows from the target environment. - Results are displayed in a full-width, horizontally scrollable table with columns auto-detected from the response.
Note: The current environment appears in the dropdown as
"Current"and is disabled — it cannot be used with the cross-environment action.
GetOrganizations()
│
▼
Environment Dropdown ──► Editable URL Textbox
│
▼
User Input (Environment URL + Table Name)
│
▼
CrossEnvFetcher.tsx (React UI component)
│
▼
CrossEnvDataverseService.ts (wrapper service)
│
▼
@microsoft/power-apps → Microsoft Dataverse Connector
│ (ListRecordsWithOrganization)
▼
Target Dataverse Environment
- Power Apps CLI (PAC CLI) v1.46 or later
- A Power Platform environment with Dataverse enabled
- The Microsoft Dataverse connector added to the project (already configured)
- An active connection to the connector in Power Apps
- Authenticated via PAC CLI:
pac auth create --environment <envId>
# Install dependencies
npm install
# Build for production
npm run buildNote:
tsc -breports pre-existing errors in the auto-generatedMicrosoftDataverseService.ts(invalid parameter syntaxMSCRM.IncludeMipSensitivityLabel). The Vite build succeeds and the app runs correctly — these TypeScript strict-mode errors do not affect runtime behavior.
Since the app uses the Microsoft Dataverse connector, it must be published to Power Apps to function. Local development (npm run dev) will not have access to connector APIs.
# Build and push to Power Apps
npm run build
pac code push- Open the published app in Power Apps.
- The Environment dropdown auto-populates with all accessible environments.
- Select a target environment (or manually edit the URL in the textbox below the dropdown).
- Enter a Table Logical Name (e.g.,
accounts,contacts). - Click Fetch Data.
- Verify that rows from the target environment's table are displayed in the results table.
- Open the browser Console (F12) to see
[CrossEnvFetcher]trace logs for debugging.
Tip: You can find the environment URL in the Power Platform Admin Center under the environment's details.
src/
├── components/
│ ├── CrossEnvFetcher.tsx # Main UI — form + results table
│ └── CrossEnvFetcher.css # Component styles
├── services/
│ └── CrossEnvDataverseService.ts # Wrapper for GetOrganizations + ListRecordsWithOrganization
├── generated/ # Auto-generated (do not edit)
│ ├── models/
│ │ └── MicrosoftDataverseModel.ts
│ ├── services/
│ │ └── MicrosoftDataverseService.ts
│ └── index.ts
├── App.tsx # App entry point
├── App.css # App-level styles
└── main.tsx # Vite entry point
.power/
├── schemas/
│ ├── appschemas/
│ │ └── dataSourcesInfo.ts # Connector configuration
│ └── commondataserviceforapps/
│ └── commondataserviceforapps.Schema.json
power.config.json # Code App configuration
Lists all Dataverse environments the current user has access to. Used to auto-populate the environment dropdown on app load. Returns Url and FriendlyName for each environment. No additional connectors needed — uses the same Microsoft Dataverse connector, avoiding DLP policy issues.
| Parameter | Description |
|---|---|
organization |
Target environment URL |
entityName |
Dataverse table logical name |
$select |
(Optional) Comma-separated column names |
$filter |
(Optional) OData filter expression |
$top |
(Optional) Max rows to return (default: 2000) |
- Read-only — this POC only fetches data (no create/update/delete).
- No local testing — connector calls require the Power Apps runtime.
- Dynamic schema — column types are not known at compile time; all values render as strings.
- No pagination — fetches up to 50 rows per request (configurable via
$top). - Current environment —
GetOrganizationsreturns the current environment withUrl: "Current"(not a real URL), so it is disabled in the dropdown. - The auto-generated
MicrosoftDataverseService.tshas a known TypeScript syntax issue withMSCRM.IncludeMipSensitivityLabel— this is a code-gen bug and does not affect functionality.
The app logs trace messages to the browser console with the [CrossEnvFetcher] prefix:
- Organizations loaded (full response, count, auto-selection)
- Dropdown selection and manual URL edits
- Fetch parameters (
organization,entityName,$top) - Fetch results (raw response, row count, detected columns)
- Errors (full error object)
Open F12 → Console in the browser to view these logs.