Dataverse
Use when the Power Apps app or the flow reads or writes Dataverse tables: writing or fixing a formula that filters, sorts, compares or writes a Dataverse column; finding the right table or column name (logical, display, schema, publisher prefix); deciding Choice, Lookup or text; building or updating the AS-BUILT-NAMES; delegation on the Dataverse connector (what delegates, 500/2,000); designing a security role, business unit, owner team or column security; modeling a table, relationship, alternate key or calculated column; importing CSV or Excel. Terms: \"what is the column name\", \"Choice or text\", \"user sees all units\", \"import a spreadsheet\". Do not use for screen YAML, Power Fx outside Dataverse, combo boxes and UX (use `powerapps-canvas`), flows, `$batch` and HTTP (use `power-automate`), procedures and SQL Server (use `sql-procedures`), solutions, environments and connection references (use `power-platform`).
ByBrunoPower Platform developer- name:
- dataverse
- description:
- Use when the Power Apps app or the flow reads or writes Dataverse tables: writing or fixing a formula that filters, sorts, compares or writes a Dataverse column; finding the right table or column name (logical, display, schema, publisher prefix); deciding Choice, Lookup or text; building or updating the AS-BUILT-NAMES; delegation on the Dataverse connector (what delegates, 500/2,000); designing a security role, business unit, owner team or column security; modeling a table, relationship, alternate key or calculated column; importing CSV or Excel. Terms: \"what is the column name\", \"Choice or text\", \"user sees all units\", \"import a spreadsheet\". Do not use for screen YAML, Power Fx outside Dataverse, combo boxes and UX (use `powerapps-canvas`), flows, `$batch` and HTTP (use `power-automate`), procedures and SQL Server (use `sql-procedures`), solutions, environments and connection references (use `power-platform`).
Dataverse in Power Apps apps
This skill delivers what the app and the flow need to know about Dataverse to avoid mistakes: the
right name of each table and column in the real environment, the real type (Choice, Lookup or
text) and the syntax it requires, what delegates, who can read which rows, how to model and how to
import. The central artifact is the project's AS-BUILT-NAMES.md.
Boundaries: what lives here is how the Dataverse column shows up in Power Fx, the alternate key
and the table. The rest of Power Fx belongs to powerapps-canvas; $batch and the flow belong to
power-automate; ALM (solution, environment, environment variable) belongs to power-platform.
Decided standards (N1-N3, A3, A4) are in skills/power-platform/references/default-decisions.md --
this skill points to them, it does not repeat them.
Non-negotiable rules
- Read the project's
AS-BUILT-NAMES.mdbefore writing or judging any formula or flow that touches Dataverse. The data dictionary, the creation script and the plan lose to it (N1). Path inpower-platform.config.json->nomes_as_built. If the file does not exist, the first step is to extract it (references/as-built-names.md), not to guess. Why: a screen written against the dictionary needed several fixes in Studio; all were name and type, none was syntax. - One name per context. An identifier in a formula = display name; text between double
quotes (
SortByColumns,DisplayFields,SearchFields), OData, Web API and$batch= logical name; the$batchURL = EntitySet (plural). Never derive one name from another. Why: the logical name does not follow from the display name by any rule, and a column error in a string fails silently. - Real type before syntax. Choice compares with an option, Lookup with a record, text with text.
Confirm the
AttributeTypein the as-built before writing theFilteror thePatch. Why: the real environment swapped Lookup for Choice and for text; the syntax changes in each case. - Before saying a column does not exist, open the whole table schema -- never a filtered
extract or a sample (N3).
Why: an extract with
$filteror a sample export omits columns and produces a false "does not exist". - Every query declares what delegates, and the test is
Data row limit = 1in Studio. The absence of a yellow triangle does not prove delegation. Why: a non-delegated query downloads 500 (up to 2,000) rows and filters on the client, with no error. - A screen filter is not access control (A3). A Security Role at Organization scope lets any user with access to the table read all units through Excel, Power BI or the Web API. Row isolation requires Owner Team + Business Unit, or the accepted risk is written down. Why: the unit scope in the gallery is a convenience; whoever reads straight from the API ignores the gallery.
- A single owner of schema creation per environment: script or maker, never both. Once the schema is created, extract the as-built and write against it. Why: the real environment was created by hand with the tenant's default publisher, with a prefix and types different from the script's.
- Upsert and
$batchby business key require an alternate key inActivestate. Why: aPendingkey resolves neither Lookup on import nor upsert, and the error is silent. - Text does not become Choice or Lookup later. Decide the type before importing; importing
first and adjusting later means rebuilding the table.
Why: the import wizard creates text columns and Dataverse does not convert them. The mockup load
of
/pp-en:architectureexists to get the type wrong on the mockup, where recreating is free. - Never claim "✅ done" about a name or type without the command that finds the evidence again
(a dated extraction from the environment). Why: P2 and P5 in
default-decisions.md.
Workflow
Classify the task and load only what is needed:
Task Load Write/fix a formula or flow that reads or writes a Dataverse column references/names-and-types.md+ the project'sAS-BUILT-NAMES.md"What is the right name of...", build or update the as-built references/as-built-names.md,assets/as-built-names-template.md,scripts/extrair-nomes-as-built.pyAudit delegation, counter, truncating gallery references/dataverse-delegation.md"Any user sees all units", role, BU, owner team references/security.mdCreate table, relationship, key, calculated column, auditing references/modeling.mdImport CSV/Excel, migrate legacy data, load with Lookup references/data-import.mdCreate the tables from the .xlsxmockup load; check the types Dataverse inferredskills/power-platform/references/mockup-load.mdandscripts/montar-carga-mockup.py --conferir(from the orchestrator)Create tables, typed columns, relationships and the mockup load straight through the Web API, by a flow skills/power-platform/references/dataverse-builder.md(montar-carga-mockup.py --flow)"Has this happened before?" (field lessons) references/field-lessons.mdConfirm the track. The project's
trilha_dadosmust bedataverse(A4). If the question is "Dataverse or SQL Server?", do not decide here: point to the technology matrix (skills/power-platform/references/technology-matrix.md) and to the project's ADR. Signs that push toward SQL: corporate data already in SQL, a DBA who owns the schema, a strong multi-table transaction, gallery volume above the delegation cap. Switching tracks requires an ADR.Read the as-built (rule 1). Note what is marked
?or "not confirmed": those are gaps, and a formula that depends on them says so in writing.Write or audit using the reference for the task. A delivered formula carries its destination (
formula bar (en-US: , and ;)orpasted YAML (, and ;), seedefault-decisions.md§3) and its declared delegability (T7).Close with the definition of done below. Did a name or type change in the environment? Re-extract the as-built before moving on.
References
| File | When to read |
|---|---|
references/names-and-types.md |
Publisher and prefix; logical × display × schema × EntitySet; how Power Fx resolves in each context (row scope!); Choice × Lookup × text: compare, filter, write |
references/as-built-names.md |
Why it is the authority; how to extract (maker, Web API, pac); how to maintain and version |
references/dataverse-delegation.md |
What delegates in Dataverse, difference from the SQL connector, 500/2,000, 50,000, In, StartsWith, CountRows |
references/security.md |
Security role, BU, owner team, row scope, column security, the risk of Organization scope |
references/modeling.md |
Tables, ownership, relationships, alternate keys, calculated and rollup columns, auditing |
references/data-import.md |
CSV/Excel/dataflow, load order with Lookup, how to avoid script × environment divergence |
references/field-lessons.md |
Field lessons: what has already gone wrong in real projects and which rule prevents it |
assets/as-built-names-template.md |
Copyable template of AS-BUILT-NAMES.md |
Scripts
<skill-folder> is the Base directory shown when the skill is loaded. Run from the project root (the script looks for power-platform.config.json from the current directory upward) or pass --config.
| Command | What it checks | Exit |
|---|---|---|
python <skill-folder>/scripts/extrair-nomes-as-built.py <export.json> --prefixo <prefix>_ |
Validates the Web API JSON (EntityDefinitions + Attributes): E001 JSON/format, E002 table without attributes, E003 prefix without a table, A001 column without a display name, A003 Choice without options, D001 repeated display name |
0 no error · 1 with error · 2 usage |
… --complemento <prefix>_<table>=<choices.json> (repeatable) |
Merges Choice options and Lookup targets coming from the queries with a cast; E004 table does not exist, E005 unreadable file | 0 / 1 / 2 |
python <skill-folder>/scripts/extrair-nomes-as-built.py <export.json> --prefixo <prefix>_ --saida AS-BUILT-NAMES.md |
Same, and generates the markdown in the template's format. Writes only with --saida (- prints); refuses to overwrite the input; no network |
0 / 1 / 2 |
The script only reads a local file; the export itself (one query to the Web API) is done by you in
the authenticated browser -- step by step in references/as-built-names.md.
Definition of done
Commands from the project root (note under Scripts); the repository lint runs from the repository root.
- The as-built exists, is from the current environment and carries the extraction date.
Evidence:
python <skill-folder>/scripts/extrair-nomes-as-built.py <export.json> --prefixo <prefix>_ --saida <as-built path>->0 error(s). - Every table and column cited in the formula or flow appears in the as-built with the same name.
Evidence:
rg -n "SortByColumns|DisplayFields|SearchFields|ShowColumns" <screens folder>; each listed string is a logical name present in the as-built. - Every
Filter/Patchon Choice, Lookup or text uses the syntax of the real type. Evidence:rg -n "\.Selected\b" <screens folder>with no.Valuewhere the column is Choice. - Delegation declared and tested. Evidence: Studio with
Data row limit = 1, gallery and counters checked; result noted in the screen header (T7). - Security: isolation was tested outside the app. Evidence: with a test account from another
unit,
GET <org>/api/data/v9.2/<EntitySet>?$top=5returns only the permitted rows -- or the accepted risk is recorded in writing. - If there is an upsert by key:
GET .../EntityDefinitions(LogicalName='<table>')/Keys?$select=SchemaName,EntityKeyIndexStatus->Active. -
python tools/lint_skills.py skills/dataverse->0 error(s).
Pitfalls
- Writing against the dictionary instead of the environment -- as-built-names.
- Schema name in a formula, or display name in
SortByColumns-- names-and-types. - In row scope Power Fx resolves a column by its display name;
Distinct(…, <prefix>_column)inOnStarttook down all the globals -- names-and-types. - Comparing Choice with text or with a record; writing text into a Choice -- names-and-types.
- Primary key whose display name equals the table's (
'table'needs quotes) -- names-and-types. - Trusting the absence of the delegation triangle;
With/Setover a source -- dataverse-delegation. CountRowswith no filter is approximate (cache); a counter that shows 50000 may be the broken query -- dataverse-delegation.- A Security Role at Organization scope treated as isolation -- security.
- Lookup swapped for text with no integrity: an invalid unit gets in, a homonym collides -- modeling.
- Importing before creating Choice, Lookup and key -- data-import.
- Trusting the type Dataverse inferred from Excel: it is often wrong; check with
--conferirbefore the real data, or create through the builder, which sends the spec's type --skills/power-platform/references/mockup-load.md,dataverse-builder.md.
Open this reference as its own page
AS-BUILT-NAMES: the authority on names and types
AS-BUILT-NAMES.md is the contract of names from the real environment: tables, columns, types,
keys, Choices and connectors, read from where the data lives. When it diverges from the data
dictionary, the creation script or the plan, it wins (default-decisions.md N1). Template in
assets/as-built-names-template.md.
Contents
- Why it is the authority
- What it must contain
- How to extract from the environment
- How to generate the file
- How to maintain
- What to do about divergence
1. Why it is the authority
Three sources seem to give a column's name, and only one is the environment:
| Source | Describes | Reliable for name/type? |
|---|---|---|
| Data dictionary / plan | What was intended to be created | No |
| Creation script | What would be attempted | Only if it is what created the environment |
| Environment (maker, Web API) | What exists | Yes |
In a reference project, a user-registration screen was written against the dictionary and had to be
fixed in several places in Studio. None was syntax; all were name or type: tables with another name,
a prefix different from the planned one, perfil became a Choice (not a Lookup), unidade became
text (not a Lookup). The environment had been created by hand (or by Excel) with the tenant's default
publisher, not by the script. [verified: reference project] -- detail in
references/field-lessons.md.
Rules that follow from this:
- No screen or flow before the as-built is filled in (N2).
- Before claiming a column does not exist, open the whole table schema -- not a filtered extract, not a data sample (N3). A Dataverse data export to Excel carries few rows per table and can leave out tables the app uses: absence in the export is not absence in the environment.
- The dictionary remains useful as intent; when the divergence is deliberate, it becomes a
recorded decision, not a silent deviation (
references/modeling.md).
2. What it must contain
| Section | Content | Why |
|---|---|---|
| Header | Publisher prefix, environment (<environment>), date and command of the extraction |
P5: a number or fact without the command that measures it goes stale |
| Tables | Source name in the app, logical name, EntitySet, primary key, primary name | Formula, flow and $batch each use a different name |
| Columns | Display, logical, real AttributeType, type in Power Fx, notes |
Decides the filter and Patch syntax |
| Choices | Name in Power Fx and options with integer value | Contract with the load CSV and with the external system |
| Alternate keys | Columns and EntityKeyIndexStatus |
Upsert and import |
| Connectors | Connector name in the environment's language | In a pt-BR environment the connector object is translated (UsuáriosdoOffice365) |
| Gaps | Columns marked ? or "not confirmed", and why they do not block |
A formula that depends on a gap says so |
A schema name or type not read stays ?, never invented and never copied from the dictionary.
3. How to extract from the environment
Preferred: the Web API EntityDefinitions, because it returns whole names (maker screenshots
truncate long names) and real types. Source:
Query table definitions using the Web API.
3.1 Through the browser (what the reference projects used)
The environment host session (<org>.crm.dynamics.com) is separate from the maker session: opening
/api/data/... directly returns HTTP 401. Open https://<org>.crm.dynamics.com/main.aspx once,
complete the sign-in, and the URLs below answer JSON in the browser itself. [verified: reference project]
Save each response to a .json file.
Tables and columns in a single call (script input):
https://<org>.crm.dynamics.com/api/data/v9.2/EntityDefinitions?$select=LogicalName,SchemaName,EntitySetName,PrimaryIdAttribute,PrimaryNameAttribute,DisplayName&$filter=startswith(LogicalName,'<prefixo>_')&$expand=Attributes($select=LogicalName,SchemaName,AttributeType,AttributeTypeName,DisplayName)
$expand=Attributes only brings the common properties: OptionSet and Targets do not fit in
the inner $select (Learn, page above). For them, a call with a cast per table:
# Choice options (and global Choice)
https://<org>.crm.dynamics.com/api/data/v9.2/EntityDefinitions(LogicalName='<prefixo>_<tabela>')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet
# Lookup target
https://<org>.crm.dynamics.com/api/data/v9.2/EntityDefinitions(LogicalName='<prefixo>_<tabela>')/Attributes/Microsoft.Dynamics.CRM.LookupAttributeMetadata?$select=LogicalName,Targets
A global Choice by name (does not accept $filter):
https://<org>.crm.dynamics.com/api/data/v9.2/GlobalOptionSetDefinitions(Name='<choice name>')
Metadata has no paging and no row limit: the first response brings everything. In an environment with
several languages, add &LabelLanguages=<LCID> to shorten it (pt-BR = 1046).
3.2 Through the maker (manual check)
In make.powerapps.com -> Tables -> the table -> Columns: shows the display name, name (logical)
and type. Useful to check a single column; it is not an extraction, because the grid truncates
long names (<prefixo>_dataprevistadeencerramentod…). A name truncated in the screenshot goes into
the as-built as "truncated -- do not use in SortByColumns/DisplayFields/SearchFields until read in full".
3.3 Through Studio
The app's data panel shows the name under which the table was added (the data source in Power Fx), which can differ from the table's display name. The connector appears in the connections panel with the translated name. These two names can only be read in the app, not in the Web API.
3.4 Through pac and an exported solution
[unverified]: the reference projects did not have pac installed and did not use this path.
Candidates for an environment that has it: export the solution and read customizations.xml; or
pac modelbuilder build, which generates classes with the logical names. If you use it, record the
command and the result in the as-built, as with the Web API.
4. How to generate the file
python <skill-folder>/scripts/extrair-nomes-as-built.py <export.json> --prefixo <prefix>_ `
--complemento <prefix>_<table>=<table-choices.json> `
--saida <path of AS-BUILT-NAMES.md>
(The backtick line continuation is PowerShell; in bash use \.) (--complemento is repeatable;
without --saida the script only validates.) The script reads only a local file, with no network,
and writes only to --saida; never over the input. It:
- filters tables and columns by the prefix (system columns and the primary key come in as the case requires);
- translates
AttributeTypeinto the type in Power Fx and the comparison rule (references/names-and-types.md§7); - flags the primary key whose display name collides with the table's (quotes required);
- reports a table without attributes (
E002), a Choice without options (A003), a repeated display name (D001).
The generated file is generator output (P3): mark it "generated -- do not edit", and take a manual correction to the input (redo the export). The parts the Web API does not give -- the source name in the app, the connector name, modeling decisions -- go in a separate, hand-written section that the generator does not touch (copy the template and keep the two sections in separate files if you prefer).
5. How to maintain
- Version it in Git next to the app; the as-built diff is the best warning that the environment changed.
- Re-extract on every schema change, every new table and before any wave of screens. Whoever changes the environment (maker or script) is who re-extracts.
- Write the date and the command in the header. A document that states a number or fact carries the command that measures it (P5).
- Point to the path in
power-platform.config.json(nomes_as_built) for humans and agents. Thevalidar-telas.pyonly checks the publisher prefix (T014); checking a name against the as-built is manual (or withextrair-nomes-as-built.py+ reading). - Do not fill a gap by inference: if a screen depends on a
?column, the pending item is recorded and the screen avoids the dependency (e.g. sort withSort(...)instead ofSortByColumns(...)until the logical name is read).[verified: reference project]-- that defense nullified the only wrong name guess in a round of screens.
6. What to do about divergence
When the as-built differs from the dictionary, decide and write it down -- do not leave the deviation as a fact of life:
| Option | Cost | When |
|---|---|---|
| Keep the as-built | Fast; loses the integrity the dictionary foresaw (Lookup -> text) | Small table, low risk, short deadline |
| Realign the environment to the dictionary | Recreate tables and re-import | When integrity or a closed domain is a requirement |
| Update the dictionary | Cheap | When the environment is right and the paper was wrong |
The decision applies to each table, and it changes the filter and Patch syntax of the following
screens -- which is why it is a prerequisite for them. Record it in a project ADR (default-decisions.md, A4 and §8).
Open this reference as its own page
Data import into Dataverse
CSV, Excel and dataflow; load order with Lookup; checking; and how to avoid the divergence between the script and the environment. Source of the facts: the data plan and the CSV package of a reference project, and the way the real environment ended up being created.
Contents
- The rule that decides everything
- Choosing the path
- Mandatory order
- File format
- Lookup and Choice on import
- Prepare the legacy data before generating the CSV
- Checking the load
- How to avoid the script × environment divergence
1. The rule that decides everything
The maker's "Import data" wizard creates TEXT columns, and Dataverse does not convert text into
Choice or Lookup afterwards. Importing first and adjusting later means rebuilding the tables.
[verified: reference project] -- it was also the origin of the real environment's divergence: tables created
by Excel import have text columns where the plan foresaw Choice and Lookup.
To avoid it: create Choices, tables, columns, Lookups and alternate keys first; import data into that structure, mapping each column of the file to the existing column. Importing into a new table generated by the wizard only makes sense when all the columns should be text.
Exception: the mockup load of /pp-en:architecture (skills/power-platform/references/mockup-load.md) is made for this.
- It creates the structure with fictitious data, lets the type inference get it wrong there and goes through
the check (
montar-carga-mockup.py --conferir) before any real data. - Recreating a column that only has mockup rows is free.
- Or, with no inference: the builder (
skills/power-platform/references/dataverse-builder.md) creates the tables, the columns with the spec's type, the Lookups and the mockup rows through the Web API. - Real data keeps going in through this reference, into a table that already exists.
2. Choosing the path
| Path | When | Attention |
|---|---|---|
| Import from CSV/Excel (maker, Import data) | One-off or rare load, clean file, structure already created | Maps to existing columns; resolves Choice by label and Lookup by the primary name column or alternate key |
| Dataflow (Power Query) | Recurring load, transformation (cleaning, join, types), external source | Maps and transforms; allows a key to update existing rows [unverified] -- read the dataflows Learn page before counting on upsert |
Flow (Add a new row, $batch) |
Programmatic load, small/medium volume, business rule on entry | Respects the flow's rules; large volume calls for batching (power-automate) |
| Connector/data tool | Large migration, between systems | Outside the scope of this skill |
Sources: Import data and
Dataflows.
This document describes the practice of the reference projects (CSV); dataflow details are
[unverified] in this repository.
3. Mandatory order
1. Create the Choices (global, if shared)
2. Create the tables and the columns (Lookup included) — by hand, through the mockup load or through the builder, checked with --conferir
3. Create the alternate keys → wait for EntityKeyIndexStatus = Active
4. Extract the as-built and check it against the plan (references/as-built-names.md)
5. Import, in dependency order: catalogs → profiles/users → links → transactional → trail
The order in step 5 is that of the Lookup dependencies: a row can only point to something that already exists. With a circular dependency, import without the Lookup and fill it afterwards.
Step 3 is not a detail: a Pending key does not resolve Lookup on import and the error is silent
(the row goes in without the link, with no message) [verified: reference project].
4. File format
[verified: reference project] except where marked:
| Item | Rule |
|---|---|
| Encoding | UTF-8 with BOM (the maker wizard reads accents without breaking) |
| Separator | , -- the import does not reliably accept ;. The output CSV for a pt-BR Excel uses ;: they are files for different purposes |
| Date | ISO: YYYY-MM-DD (date) and YYYY-MM-DDTHH:MM:SSZ (date and time). The spreadsheet import has swapped day and month before: check one date after importing (field-lessons.md §8) |
| Yes/No | The environment's label (Yes/No in en-US; Sim/Não in pt-BR) |
| Choice | The option's label (not the integer value) |
| Lookup | Value of the target's primary name column, or of the alternate key chosen in the mapping step |
| System columns | None (createdon, ownerid, statecode, etc.) |
| Text with a leading zero | Treat as text at the source; Excel strips zeros. Standardize beforehand (e.g. a code with leading zeros) |
| First row | Header with the display names of the target columns, as in the as-built |
Generate the header from the as-built, not from the dictionary (§8).
5. Lookup and Choice on import
- Choice: the wizard resolves by label. A label with an accent or space different from the environment's option does not match; check against the as-built options.
- Lookup: resolves by the target's primary name column. If the primary name is not unique (a business rule allows duplicates), the resolution is silently wrong or fails at the first duplicate. Use an alternate key and choose it in the mapping step.
- When the target only has a numeric business key from the legacy system, include in the child
table's file an auxiliary column with that key (e.g.
<target>_legacy_id) and use it as the match.[verified: reference project]-- that is how child records and the trail pointed to the parent. - Text instead of Lookup (as-built with text): nothing resolves; the value goes in as it came. Validate beforehand against the source table (§6).
6. Prepare the legacy data before generating the CSV
Run the consistency check before generating the files, not on the eve of go-live. Example queries (adapt the source; here in illustrative SQL, destination: the source's SQL client):
-- rows that violate a business rule and will be blocked on load
SELECT COUNT(*) FROM <tabela>
WHERE (<tipo> = 'A' AND <campo_b> <> 'X') OR (<tipo> <> 'A' AND <campo_b> = 'X');
-- nonexistent unit values (the defect that the lack of a Lookup lets in)
SELECT <unidade> FROM <tabela_usuarios>
WHERE <unidade> NOT IN (SELECT <codigo> FROM <tabela_unidades>);
-- dates outside ISO format
SELECT <id>, <data> FROM <tabela> WHERE <data> NOT LIKE '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]';
Typical transformations ([verified: reference project]):
| Field | Transformation | Reason |
|---|---|---|
| Date as text | Convert to ISO and validate the format beforehand | The column never had a format constraint; there may be a 01/05/2026 |
| Numeric identifier with zeros | Pad with a leading zero | Excel strips them |
| Reference code | Upper case | Normalization business rule |
| Fields derived at the source (region, etc.) | Discard | They derive from the unit; do not duplicate |
| Password hash | Discard | Identity belongs to Entra |
Measure what Dataverse will require (modeling §9): a required field that the legacy data does not fill brings the whole load down.
7. Checking the load
- Count: compare the number of rows in the file with the table's. Use
CountIf(<Table>, true)(exact up to 50,000), notCountRows(<Table>)with no filter, which is approximate (cache) --references/dataverse-delegation.md§3. Above 50,000, count by flow or through the Web API:$count=truesaturates at 5,000 (default);RetrieveTotalRecordCountreturns a snapshot of the last 24 h, not the exact current number. - Links: child rows without the Lookup filled = alternate key not active or wrong match.
Count:
Filter(<Child>, IsBlank(<lookup>))(the result should be 0 or the expected number). - Choices: no Choice column was left blank because a label did not match.
- Sample: check edge rows (accent, leading zero, boundary date).
- Keep the command and the result with the date (P5).
8. How to avoid the script × environment divergence
The root cause of the rework in the reference projects was writing against what should exist.
- One owner of creation (
references/modeling.md§1). If the environment was created by hand, the creation script is discarded or rebuilt from the as-built, not reused. - Extract the as-built after creating and before generating any CSV, screen or flow.
- Generate the CSV and the mapping from the as-built, never from the dictionary. The file header is the display name the as-built says.
- Re-extract after any change and compare (diff) with the versioned as-built.
- Record divergence as a decision (keep, realign, update the dictionary;
references/as-built-names.md§6). - Re-importing does not repair a wrong type: if a column was born text and should be Choice, the way is to recreate the column and reload, not "import again on top".
- A CSV generator is an example, not a standard. The one from a reference project generated the files from the source database and the dictionary; it serves as a model of how to validate before generating, but the contract is the as-built.
Open this reference as its own page
Delegation in the Dataverse connector
What Dataverse delegates, what it does not, the limits and how to test. The app side (how to write the
gallery, OnStart, counters) belongs to powerapps-canvas; this reference covers what is specific
to the Dataverse connector and how it differs from the SQL Server connector.
Contents
- The rule and the cap
- Dataverse connector matrix
- Counting and aggregation
- In, StartsWith, Search
- Dates
- Silent pitfalls
- Dataverse vs SQL Server
- When it does not delegate: alternatives
- How to test
1. The rule and the cap
- If any part of the expression does not delegate, no part delegates: the app downloads the first 500 rows (adjustable up to 2,000, in Settings > General > Data row limit) and filters on the client, with no error. Source: Understand delegation.
- The warning (yellow triangle) only appears on formulas over a delegable source and does not cover everything. No warning does not prove delegation. Test with a limit of 1 (§9).
- The wrong result "looks right": it is silent truncation (the most expensive class of defect in a Canvas app). Every query
declares in writing what delegates (
default-decisions.mdT7).
2. Dataverse connector matrix
Transcribed from the connector table (Connect to Microsoft Dataverse, read 2026-10). The connector table is the authority: what is not in it does not delegate.
| Operation | Number | Text | Choice | DateTime | GUID |
|---|---|---|---|---|---|
< <= > >= |
yes | yes | no | yes | - |
= <> |
yes | yes | yes | yes | yes |
And / Or / Not |
yes | yes | yes | yes | yes |
Filter, LookUp, Sort, SortByColumns |
yes | yes | yes | yes | Filter/LookUp: yes |
First |
yes | yes | yes | yes | yes |
In (belongs to a list) |
yes | yes | yes | yes | yes |
In (substring) |
- | yes | - | - | - |
IsBlank |
yes | yes | no | yes | yes |
Search |
no | yes | no | no | - |
StartsWith |
- | yes | - | - | - |
CountRows, CountIf |
yes | yes | yes | yes | yes |
Sum, Min, Max, Avg |
yes | - | - | no | - |
Notes from the official table that change formulas:
- Number: an arithmetic expression on the column (
Filter(t, col + 10 > 100)) does not delegate; a cast to number does not either; a column the app sees as a number but the backend does not store as a plain number (currency) does not delegate. - Text:
Trim,Trim[Ends]andLenare not supported;Left,Mid,Right,Upper,Lower,ReplaceandSubstituteare listed as supported in the official note;Text(col)is not. A reference project recordedUpper/Lower/Left/Midover a column as not delegable in practice[verified: reference project, differs from the official note]— test before using. - DateTime delegates, except the
Now()andToday()functions (see §5). CountRowsuses a cached value (see §3).- For
CountRows, the user needs permission to get table totals. - Every aggregation is capped at 50,000 rows and does not work on views.
FirstNis not supported.Inis subject to the limit of 15 tables per Dataverse query (connector note). Another source in a reference project cites 20 entities per query on another page; the documentation is inconsistent[unverified which one holds].IsBlankaccepts comparisons (col = Blank()), but not on Choice.UpdateIf/RemoveIfonly simulate delegation up to 500/2,000 records.
Outside the table and therefore not delegable: EndsWith, Distinct, GroupBy/Ungroup, ForAll,
Concat, Collect/ClearCollect, Choices, With, If inside the predicate, Left/Mid/Right
over a column (according to a reference project), exactin, StdevP/VarP, local collections as a source.
EndsWith appears in the general delegation list but not in the Dataverse connector table: treat it as not
delegable and validate it in Monitor [verified: reference project].
Structural query limits (cited by a reference project from Learn, not reconfirmed):
conditions per OData query ≈ 500 (TooManyConditionsInQuery), lookup/expand levels = 2,
$expand clauses = 10, strings in an In ≈ 850 characters in total
(Filter rows using OData)
[unverified]. To reduce conditions, use In/NotIn instead of a chain of Or.
3. Counting and aggregation
Unlike SQL Server, Dataverse delegates counting, with three caveats:
| Use | Delegates | Cap | Accuracy |
|---|---|---|---|
CountRows(Table) with no filter |
yes | no hard cap | approximate (cached value) |
CountRows(Filter(Table, …)) |
yes | 50,000 | exact up to the cap [unverified: a reference project says it requires the "Enhanced delegation for Microsoft Dataverse" option; the connector page does not mention it] |
CountIf(Table, cond) |
yes | 50,000 | exact up to the cap |
CountIf(Table, true) |
yes | 50,000 | exact — bypasses the CountRows cache |
Source: connector note 4 and Count, CountA, CountIf, CountRows.
Consequences:
CountRowswith no filter serves "roughly how many"; to check a load useCountIf(Table, true)(references/data-import.md).- A counter that shows
50000may be the broken query, not the volume.IfError(..., 50000)masks a failure with the exact number of the cap. Show the error, or—, never a plausible number.[verified: reference project] - Aggregation on a view does not work; a view resolves the filter on the server, but turns off
Sum/CountIf. - Above 50,000, aggregate on the server (flow, materialized view, summary/rollup column).
4. In, StartsWith, Search
col in [list]andcol in collection(column of the base table) delegate; the docs only exemplifyinwith a literal array, and delegation against a variable collection is shown by a third-party blog (not by documentation). Validate with limit 1[unverified].col in [list]over a column of another table (through a relationship) does not delegate."text" in col(substring) delegates on Text, but is equivalent toLIKE '%x%'and does not use an index: Microsoft prefersStartsWith(Optimized query data patterns). Do not confuse the twoin.StartsWith(column, text)delegates and uses an index; the column goes on the left. So does equality:column = variable, notvariable = column, or the expression does not delegate[verified: reference project].Searchdelegates only on text columns;SearchFieldswith a wrong name fails silently (references/names-and-types.md§3).
// formula bar (en-US: , and ;)
// Delegates: column on the left, text, StartsWith
Filter(
Pedidos,
StartsWith(unidade, varUnidadeFiltro),
situacao = 'situacao (Pedidos)'.Aberto
)
Beware of the scope filter "" = "all": StartsWith(unidade, "") is true for every
row with a value, and leaves out a row with an empty unidade. If empty must mean "all",
handle the case (IsBlank(varUnidadeFiltro) || … breaks delegation — prefer two If branches
outside the Filter, or make the column required). [unverified in Dataverse; in SQL the idiom delegates — verified]
5. Dates
DateTime delegates in Dataverse. The exception is the Now()/Today() function (connector note 3), which conflicts
with the general delegation page (which says Today() "folds to a constant" and does not block).
Treat it as a risk and remove the doubt:
// formula bar (en-US: , and ;)
// OnStart or OnVisible: compute the date once
Set(varLimite, DateAdd(Today(), -30, TimeUnit.Days));
// Filter: the variable is a constant, the column stands alone on the left
Filter(Pedidos, data_pedido >= varLimite)
Careful not to swing to the other extreme: With(…) around the source breaks delegation without a warning
(§6). The variable must be a scalar (Set), not a With that wraps the table.
6. Silent pitfalls
| Pitfall | Effect | Way out |
|---|---|---|
With, Set or UpdateContext over a source |
They create an in-memory collection: no delegation, no warning | Use With only for scalars and constants; keep the table out of it |
AddColumns/ShowColumns |
The arguments delegate, the output truncates at 500/2,000 | Project only the needed columns; do not use it as a join of a large table |
AddColumns with LookUp inside |
One network call per row (N+1) | Denormalize the column or load the small master into a collection |
Distinct(Filter(…)) |
Does not delegate; the filter list truncates | Domain table, or a flow that returns the values |
Constant inside the Filter (!varFlag && col = x) |
The constant clause does not delegate in Dataverse | If(varFlag, Blank(), Filter(…)) outside the Filter |
Choices() as a gallery source |
Does not delegate | Only for a ComboBox with few options |
IfError(…, 50000) |
A failure becomes a plausible number | Show the error |
Dataverse query inside Visible or Timer.Start |
Network on every evaluation | Variable updated on an event |
Source for the first item: Delegation overview.
7. Dataverse vs SQL Server
The same formula delegates one way on one connector and another way on the other. Changing the data track invalidates the delegation audit.
| Aspect | Dataverse | SQL Server |
|---|---|---|
CountRows/CountIf |
delegates (≤ 50,000; without a filter it is approximate) | does not delegate: show a cap (2,000+) or count on the server (B3) |
| Direct date filter | delegates | does not delegate behind a gateway: integer computed column Ref_<col> (B2) |
Sum/Min/Max/Avg |
delegates on Number (≤ 50,000) | delegates on Number |
EndsWith, Len |
no | yes (text) |
In (belongs to) |
yes | no (substring only) |
Search |
text only | text only |
* / over a column |
no | yes (number) |
| View as output | resolves the filter on the server; no aggregation | same (view) |
| Types | native Choice/Lookup/Yes/No | bit, text, number |
Origin: matrix of default-decisions.md B2/B3 and the connector table of a reference project
([verified: reference project] for the SQL column; the Dataverse column follows the Learn page above).
8. When it does not delegate: alternatives
In order of preference for Dataverse:
- View pre-filtered on the server (the one Microsoft recommends most): filter and join run on the server and the payload shrinks. Price: no aggregation.
Filter(table, col in colValues), respecting ≈ 850 characters of strings per query.- Denormalized column +
=orStartsWith(uses an index), filled by a flow, plugin or app write (references/modeling.md). - Flow that returns the result already aggregated/filtered (volume above 50,000; export).
- Accept the cap and show it (
2,000+), if the business rule allows.
Never: export from a gallery or collection (loses data without an error); use the gallery filter as the
only access control (references/security.md).
9. How to test
- Settings > General > Data row limit = 1. Every nondelegable query now returns one row, which is easy to see. This is the documentation's own recommendation.
- Walk through the screen: gallery, counters, filter combos, identity
LookUp. A single row where there should be a list = does not delegate. - Open Monitor (Advanced > Open Monitor) and check the query sent to the server: the
$filtermust contain the predicate. A missing predicate = client-side filter. - Put the limit back to 500 (or 2,000) and note in the screen header what delegates, what does not and the cap.
The audit does not end in Studio: production data has more rows than test data. Test with a data set larger than the limit.
Open this reference as its own page
Field lessons: Dataverse
Patterns that showed up in real projects and did not yet fit a single rule in the other references. Each lesson gives what happened, in generic terms, and the rule or file that prevents it. It is not a rule by itself: what holds is in the files cited.
Contents
- A workaround that makes the error disappear is not a fix
- A profile read from a Choice returns the label, not the record
- A data export is read from the zip, not opened
- A column without an owner is a dead column
- The app source → table map belongs to the app, not to the environment
- Null date and the platform's minimum limit
- Metadata and load through the Web API
- The spreadsheet import swapped day and month
1. A workaround that makes the error disappear is not a fix
| What happened | When fixing a screen written against the dictionary, three adjustments made the error disappear without touching the cause: a combo box started listing the link table instead of the catalog table (with a tautological filter X = X); a label was "flipped" for debugging because Items pointed to the wrong table; a person picker started displaying an arbitrary field (DisplayFields: ["City"]) instead of the name, because the Office 365 connector fields (DisplayName, Mail) carry no prefix and the name used did not resolve. |
| Why it is dangerous | The screen stops reporting, but starts showing the wrong data, and the workaround becomes a copied pattern. |
| Prevented by | references/as-built-names.md (the right column comes from the environment) and references/names-and-types.md §3 (a connector that is not Dataverse uses the connector's field). If the error goes away after swapping the source or the column, go back to the as-built before accepting it. |
2. A profile read from a Choice returns the label, not the record
| What happened | Set(varPerfil, varUsuario.perfil) over a Choice column returns the option's label, not the record of the profiles table. Every varPerfil.pode_* in the menu and screens read a property of a text. The fix was to resolve the profile with LookUp(<profiles table>, nome = Text(varUsuario.perfil)). The same fragile point, a different accent between the label and the profile name, made the app open empty, with no error. |
| Prevented by | references/names-and-types.md §6.1 (Choice is not a record) and references/security.md §6 (permission by flag, no resolved profile = no access). In powerapps-canvas, references/scope-and-permission.md. |
3. A data export is read from the zip, not opened
| What happened | The only "schema" source was a Dataverse data export to Excel, hundreds of MB, one sheet per table, with a few sample rows. Opening the whole file froze the usual reader. The header of each sheet (the logical names) was read straight from xl/workbook.xml and from the first row of each xl/worksheets/sheetN.xml inside the zip. The export also omitted tables the app used, and did not carry the type (Choice or text). |
| Prevented by | references/as-built-names.md §1 and §3: a data export is not a dictionary; use scripts/extrair-nomes-as-built.py, which starts from the metadata. If only the export exists, treat every column it does not show as a gap (?), stated as an inference. |
4. A column without an owner is a dead column
| What happened | In a flow-monitoring table, several columns of the parent record were always null, and a new version of the flow stopped filling columns the previous one filled (failed action, JSON sent and received, message): the HTTP indicator was null in the report for the runs of the new version. |
| Prevented by | references/modeling.md §10: define which columns every flow fills and document who fills each one. |
5. The app source → table map belongs to the app, not to the environment
| What happened | The name of the data source in Power Fx (alias) differs from the logical name and the display name, and the map between them was built by hand, by name correlation. Two sources, one singular and one plural, pointed to the same table. |
| Prevented by | references/names-and-types.md §5. The map counts as the app's as-built, not the environment's: read the app's data panel and record the date. |
6. Null date and the platform's minimum limit
| What happened | An inbound flow replaced the source's null date (0001-01-01) with 1753-01-01 before writing. The likely reason is the platform's minimum date limit [unverified: the cause was not recorded]. |
| Prevented by | When receiving a date from an external system, decide and record how the null date is written (empty or a sentinel) instead of letting the source's minimum value through without criteria. See skills/power-automate/references/dataverse-batch-upsert.md. |
7. Metadata and load through the Web API
A flow that creates the schema and loads the rows through the Web API (a plan read by an interpreter, the same design as the kit's builder) collected these points before the first run. The Source column says where each one comes from: Learn, or what was seen in the reference project.
| Point | Rule | Source |
|---|---|---|
| Component outside the solution | MSCRM.SolutionUniqueName on every metadata creation |
Learn |
Column PUT |
replaces the whole definition: GET the column, change the field, PUT everything without @odata.context, with MSCRM.MergeLabels: true so the label of another language is not erased |
Learn |
| Autonumbering on a column with data | the column is born text, the load writes the codes, then PUT with AutoNumberFormat and SetAutoNumberSeed above the last code |
Learn; PUT acceptance not verified |
Choice option with Value: null |
the platform numbers by the publisher's value prefix. Whoever does not pin the integer reads the Choice ($expand=OptionSet,GlobalOptionSet: the local one answers in one, the global in the other) and matches by label |
Learn; numbering not verified |
| Column over a global Choice | GlobalOptionSet@odata.bind: "/GlobalOptionSetDefinitions(Name='x')" |
Learn |
| Alternate key | the index is asynchronous: EntityKeyIndexStatus goes through Pending/InProgress until Active or Failed; Failed calls for ReactivateEntityKey. When searching for the key by name in a text, include the quotes, so it does not match a key with a longer name |
Learn |
| Publisher | look it up by prefix before creating; crNNN is usually the environment's default publisher: check before running |
reference project |
| Row that can run again | fixed ID (uuid5 of the table and the natural key) and PATCH with If-None-Match: *: only creates; 412 = already exists. If-Match: * only updates (skills/power-automate/references/dataverse-batch-upsert.md) |
Learn |
| Circular Lookup | the row is born without the Lookup, and a later PATCH links the two |
reference project |
| Real owner and creation date | ownerid@odata.bind: /systemusers(<id>), with the user found by internalemailaddress (e-mail encoded in the URL, ' doubled); overriddencreatedon for the opening date |
Learn; not verified for the account that runs |
The kit's builder (skills/power-platform/references/dataverse-builder.md) already follows the points
on solution, key, fixed ID and local Choice. The others apply to whoever writes another load.
8. The spreadsheet import swapped day and month
| What happened | The spreadsheet import into Dataverse swapped day and month in the dates. It also does not write owner, sharing or creation date, and that is why that project's load went to the Web API. [verified: reference project] |
| Prevented by | references/data-import.md §4. The kit's mockup load generates dates only with day 13 or later: if the import swaps them, the month is invalid and the row is rejected, instead of going in with the wrong date. After importing, check one date in the table. Owner and creation date call for the Web API (§7). |
Open this reference as its own page
Dataverse modeling for Power Apps apps
Tables, ownership, relationships, column types, alternate keys, calculated columns and
auditing — what to decide before creating, because a lot of it cannot be undone. Solution, environment and
environment variables are ALM: skills/power-platform/references/alm-environments.md.
Contents
- Who creates the schema
- Names and convention
- Table: ownership and primary name
- Column types: what to choose
- Relationship: Lookup, Choice or text
- Denormalized columns
- Alternate keys
- Calculated and rollup columns
- Requirement level
- Auditing and trail
- Checklist before creating
1. Who creates the schema
Choose one owner per environment and declare it:
| Owner | Advantage | Risk |
|---|---|---|
| Maker by hand / Excel | Fast, no prerequisite | The as-built diverges from any plan; default publisher; wrong types |
| Script (Web API) | Reproducible, idempotent, versionable | Needs a credential and maintenance; the environment can be changed from outside and diverge from the script |
| Imported solution | Reproducible across environments (ALM) | The schema is born in the source environment |
Whichever it is, after creating, extract the as-built (references/as-built-names.md) and start
writing against it. In a reference project, a complete script was written (publisher, choices,
tables, columns, Lookups, alternate keys, idempotent) and never used: the environment was built
by hand beforehand. [verified: reference project] The script did not become the authority just by existing.
If it is a script: it should read the dictionary (not embed the schema), be idempotent (skip what
exists), check the result (integer values of the Choices, EntityKeyIndexStatus) and not run against an
environment that already has hand-made tables without first extracting the as-built.
2. Names and convention
- The prefix belongs to the publisher, not to you. Create your own publisher (and the solution) before the tables; a table created outside a solution lands in the default publisher and does not export cleanly to other environments.
- An assumption of a reference project that did not hold: "without a prefix on the names we generate, Dataverse applies the
publisher's". Through the maker it is true; through the Web API the prefix must come in the
SchemaName; and the publisher of the real environment was not the planned one. Plan with an explicit<prefixo>_. - Display name = the name Power Fx will read. If formulas will be written with
status_cadastro, the column must have that display name; the human label goes in theDescriptionand in the screen tokens. Mixing a human label with a formula name is a source of errors.[verified: reference project](decision of the creation script). - The logical name cannot be derived from the display name (
references/names-and-types.md§2): do not write a document that assumes it can. - No environment name in the table name (
dev…): each environment would have a different table and ALM breaks (default-decisions.mdF5).[verified: reference project]— in one project the DEV tables haddevin the logical name and the production ones did not. - One convention per project:
snake_caseeverywhere helps port to SQL without translation.
3. Table: ownership and primary name
- Ownership (
OwnershipType): UserOwned (the row has a user/team owner — required for isolation by owner team/BU) or OrganizationOwned (no owner; catalogs and domain tables). Decide at creation: the type does not change afterwards[unverified: claim from a reference project; check on Learn]. A transactional table that may need isolation by unit is born UserOwned. - Primary name (
PrimaryNameAttribute): required on every table, it is the label in grids and Lookups. Choose a short, readable column; do not use the long narrative or a field that repeats. A "short label" column and a separate "description/note" column avoid aCoalesce(note, summary)hack on the screen.[verified: reference project] - The primary key is a generated GUID; the business uses its own key (§7).
- A table no screen uses (a "dead table") costs maintenance; if a modeling decision left it
without a function, record it (the case of a roles table when
perfilbecame a Choice).
4. Column types: what to choose
| Need | Type | Note |
|---|---|---|
| Closed domain (small, stable list) | Choice (local or global) | Validates on the server; Choices() feeds the ComboBox; a new option is a schema change, not a screen change |
| Closed domain shared across tables | Global choice | Integer values prefixed by the publisher: do not assume 1,2,3 |
| Domain that changes without a schema change (a user-maintained list) | Table + Lookup | Keeps integrity; cost: a join |
| Short code the business already uses as a key (an abbreviation) | Single line of text + alternate key on the source table | Loses referential integrity |
| Yes/No | Yes/No | col = true |
| Date only (deadline, birth date) | Date only | Removes time zones and the class of bug of comparing dates as text |
| Instant (event, audit) | Date and time, explicit time zone behavior | UserLocal for what the user sees; TimeZoneIndependent for what cannot change |
| Numeric identifier of a legacy system | Whole number | Candidate for an alternate key to import |
| Short text | Single line of text with a length | Limit the length; long text does not filter well |
Rules:
- Text does not become Choice or Lookup later. Dataverse does not convert. Changing the type means recreating the
column and migrating. Decide before importing (
references/data-import.md). - Unused Choice: a global Choice created and not tied to any column is not seen by
Choices(); the ComboBox for that option needs a literal table.[verified: reference project] - The source for types and their mapping to Power Apps is Connect to Microsoft Dataverse.
5. Relationship: Lookup, Choice or text
| Option | Integrity | Delegation | Import | When |
|---|---|---|---|---|
| Lookup | Yes (Dataverse guarantees it) | Filtering by the Lookup compares with a record; by a column of the related table: a join, avoid | Resolves by the primary name column or by the alternate key | A real 1:N relationship the business requires to be intact |
| Choice | Closed domain | = delegates |
Resolves by label | Small, stable list with no attributes of its own |
| Text with a code | None | = and StartsWith delegate |
Trivial | Short deadline; the risk is accepted (see below) |
What is lost when swapping a Lookup for text [verified: reference project]:
- Referential integrity: an invalid value gets in (a unit that does not exist); this was one of the goals of the migration.
- A homonym collides when the text is a person's name; the real link becomes another field (e.g. the UPN).
- Manual join (
LookUp/AddColumns) instead ofcol.field. - The closed domain disappears when a Choice becomes text: changing an option means editing the screen, and nothing stops the flow from writing outside the domain.
If the as-built already has text in place of the Lookup, record the divergence as a decision (keep or
realign, references/as-built-names.md §6) and compensate: validate the domain in the flow before writing,
and check the text against the source table on the registration screen.
6. Denormalized columns
A hot filter on a column of a related table forces a join and puts delegation at risk
(references/dataverse-delegation.md). The way out is to copy the column to the child table as text:
| Distance to the data | Solution |
|---|---|
| 0 levels (column of the table itself) | filter directly |
| 1 level (Lookup column) | compare the Lookup with the record |
| 2 levels (Lookup of the Lookup) | denormalized column on the child table |
[unverified: the premise that filtering by a Lookup column "gives up delegation" came from the plan of a reference project; Learn talks about a limit on lookup levels. Test with limit 1 before calling denormalization mandatory.]
Rules for denormalization: document who writes the copy (the flow, in the same action that creates the row) and when diverging is correct (the trail keeps the value in force at the event, not the current one).
7. Alternate keys
An alternate key = one or more columns that identify a row without the GUID. It is what enables upsert and import that resolves a Lookup by a business key. (Define alternate keys, for developers).
Facts:
- The key is not available right away: on save, a system job creates the index. Status:
Pending→In Progress→Active(orFailed). Through the Web API:GET <org>/api/data/v9.2/EntityDefinitions(LogicalName='<tabela>')/Keys?$select=SchemaName,EntityKeyIndexStatus. A key inPendingdoes not resolve a Lookup on import and the error is silent.[verified: reference project] - If the key column data contains
/ # < > * % & : \ ? +,GETandPATCHby key do not work (Learn, page above). Uniqueness alone is fine; for integration, choose columns without those characters. - A key can be composite (several columns). Limits from Learn: up to 10 keys per table, 16 columns and 900 bytes per key; only single line of text, whole number or decimal, date and time, Lookup and Choice columns; a column with column security cannot be in a key; keys do not exist on virtual tables (Work with alternate keys).
- Example: the order's business identifier (
id_pedido) is not unique under the business rule, so the import wizard would not resolve the Lookup by the primary name; a numericid_legadowas marked as an alternate key and the load used it as the matching column. - Example: the
$batchupsert depends on a composite key (several columns: unit, type, date); the flow builds a{key → GUID}index to separate Update from Create. With an active composite alternate key, the lookup by GUID can be replaced by addressing the row by the key (upsert),[unverified: not tested]; the$batchformat belongs topower-automate.
Define the alternate key when modeling, activate it and wait for Active before importing or bringing up the flow.
8. Calculated and rollup columns
- Calculated: a formula evaluated on read, on the row itself (Learn). Useful for display and to derive a value the screen should not assemble.
- Rollup: an aggregation over related rows, recalculated by an asynchronous job (Learn): the value is not real time.
- Do not assume that filtering by a calculated column delegates:
[unverified]— confirm in Monitor. When you need to filter by a derived value (e.g. "overdue" calculated from a date), filter by the source column (the date) and use the calculated one only to display.[verified: reference project](the deadline status column is display only; the filter uses the date). - Creation: a calculated column with a complex formula is usually made in the maker; do not assume a Web API script creates it (in a reference project it was one of the two items that stayed manual).
- For SQL, the persisted computed column belongs to
sql-procedures(B2); do not confuse it with this one.
9. Requirement level
Requirement levels in Dataverse: optional, business recommended and business required. Required breaks the load of legacy data that lacks the field.
| Situation | Decision |
|---|---|
| New rule, no legacy | Required |
| The business rule demands it, but the legacy is empty (e.g. the vast majority has no date) | Recommended in Dataverse + requirement in the flow for registration/editing |
That way the legacy comes in as it is (empty is information) and the rule holds for 100% of new records.
Before deciding, measure the legacy: [verified: reference project] — nearly
all rows came without the date the rule requires; if it were required in the schema, the whole historical load would fail.
Confirm with the operation first: if the rule was never practiced, making it required in the flow blocks
registration on day one.
10. Auditing and trail
Two different things:
- Dataverse auditing: automatic record of who changed what, per table/column, enabled
on the environment and on the table
(Manage Dataverse auditing).
Good for compliance; consumes capacity; it is not the business trail shown to the user.
[unverified]whether any reference project turned it on. - App trail table (a business event with type, old and new value, user): written by the flow in the same action as the change. It is what the history screen reads. Denormalize the unit and the business identifier into it (§6) and keep the value in force at the moment of the event.
- Flow run log tables (run and parent flow) in Dataverse itself: the log design belongs to
power-automate, but the tables belong to this skill. Define which columns every flow fills (a new version of the flow that leaves null columns the previous one filled breaks the report).
11. Checklist before creating
- Own publisher and solution created; prefix noted.
- Owner of schema creation defined (script or maker).
- Each relationship with a decision: Lookup, Choice or text, with the cost recorded.
- Each table with ownership (UserOwned/OrganizationOwned) decided, considering §3 and
references/security.md. - Alternate keys defined for everything imported or receiving upsert; plan to wait for
Active. - Choices created before the tables that use them; integer values noted.
- Requirement level checked against the legacy data.
- A closed domain left as text has validation in the flow.
- After creating: as-built extracted (
references/as-built-names.md).
Open this reference as its own page
Dataverse table and column names and types in Power Fx
What the table and the column are called in each place, how Power Fx resolves them and how each type is
compared, filtered and written. The examples use a fictional domain: table Pedidos (Orders), with
the columns situacao (Choice), cliente (Lookup to Clientes), unidade (text) and ativo (Yes/No).
Contents
- Publisher and prefix
- The four names
- Which name in each context
- Row scope: Power Fx resolves by display name
- Data source name and primary key
- Choice, Lookup, text, Yes/No: what changes
- Decision table by type
1. Publisher and prefix
Every custom table and column carries the prefix of the publisher of the solution it was
created in (<prefixo>_). The prefix belongs to the publisher, not to the project:
- Created in the maker outside your own solution, the component lands in the tenant's or environment's default publisher, whose prefix is generated and is not the one the plan expected.
- Through the Web API the prefix is not applied automatically: it must come in the
SchemaName. - Importing an Excel file into a new table creates columns with the active publisher's prefix.
Practical consequence: the plan's prefix may not be the environment's. What counts is the one in
AS-BUILT-NAMES.md. Declare it in power-platform.config.json (prefixo_publisher).
[verified: reference projects] — the real environment used the tenant's default publisher,
with a prefix different from the planned one.
2. The four names
| Name | Example | Who defines it | Where it appears |
|---|---|---|---|
Display (DisplayName) |
situacao |
Whoever created the column | Maker, Studio, identifiers in formulas |
Logical (LogicalName) |
<prefixo>_situacaodopedido |
Generated at creation, lowercase | Strings in SortByColumns/DisplayFields, OData, Web API, flow (expressions) |
Schema (SchemaName) |
<prefixo>_SituacaoDoPedido |
Generated at creation, with capitals | Creation body through the Web API; in practice the logical name is the schema name in lowercase |
| EntitySet | <prefixo>_pedidos |
Plural of the table's logical name; read the environment's EntitySetName |
Web API and $batch URL |
The logical name does not follow from the display name by a rule. Two examples from the same environment: nome_completo
became <prefixo>_nomecompleto (lost the _) and nome_curto became <prefixo>_nome_curto (kept it).
It depends on how the column was created. It has to be read from the environment (references/as-built-names.md).
[verified: reference project]
Other facts about logical names:
- The name can be truncated in maker captures (
<prefixo>_dataprevistadeencerramentod…). The Web API returns the full name; screenshots do not. - A column with a repeated display name in the table is ambiguous in Power Fx. The extractor flags it (D001).
- System columns (
createdon,ownerid,statecode) have no prefix.
3. Which name in each context
| Context | Name | Example |
|---|---|---|
Identifier in a formula (Filter, LookUp, Sort, ThisItem.col, record key in Patch) |
Display | Filter(Pedidos, unidade = "AAA") |
Text in double quotes: SortByColumns, DisplayFields, ComboBox SearchFields, and other functions that take the column name as a string |
Logical | SortByColumns(Pedidos, "<prefixo>_datadopedido", SortOrder.Descending) |
Unquoted identifier in ShowColumns/RenameColumns/AddColumns |
Display | ShowColumns(Pedidos, unidade) |
In-memory collection (ClearCollect, Table) |
The name the collection itself defines (Value, etc.); the prefix does not apply |
DisplayFields: =["Value"] |
| Non-Dataverse connector (Office 365 Users, etc.) | The connector's field (DisplayName, Mail) |
DisplayFields: =["DisplayName"] |
| Flow: dynamic content in the designer | Display | — |
Flow: expression (outputs()?['…']), Web API, $select/$filter, $batch body |
Logical | "<prefixo>_unidade": "@item()?['Cod_Unidade']" |
$batch/Web API URL |
EntitySet | POST /api/data/v9.2/<prefixo>_pedidos |
Rule of thumb: identifier = display; string = logical. [verified: reference project] — the
SortByColumns(…, "nome_completo", …) written with the display name was fixed to the logical one in Studio. The
functions that take a column name as a string (SortByColumns, GroupBy, AddColumns, ShowColumns,
RenameColumns with a string, DisplayFields, SearchFields) require the logical name.
Source for the Dataverse connector's behavior in Power Apps: Connect to Microsoft Dataverse.
4. Row scope: Power Fx resolves by display name
Inside Filter, LookUp, Sort, AddColumns and the other functions that open the row scope, the
column identifier is resolved against the columns of that scope's table, by display name. A logical
name — above all one from another table — does not resolve and the formula does not compile.
Real case [verified: reference project]: the OnStart had a chain with Distinct(…, <prefixo>_unidade),
where <prefixo>_unidade was the logical name of a column of another table. The block did not compile and
took down every global variable defined after it: every screen opened in error. Fix:
use the display name of the scope table's column and, for a column of another table, rename it first
(RenameColumns) or fetch the record (LookUp) and read the field.
// formula bar (en-US: , and ;)
// Wrong: logical name of a column of another table inside the row scope
ClearCollect(
colUnidades,
Sort(Distinct(Pedidos, <prefixo>_unidade), Value)
);
// Right: display name of the scope's column
ClearCollect(
colUnidades,
Sort(Distinct(Pedidos, unidade), Value)
);
Two consequences:
- An error in
OnStartis not local: a formula that does not compile inOnStarttakes the following globals with it. RunOnStart(app menu → Run OnStart) and check the variables pane. DisplayFields/SearchFieldsare not row scope: they are strings the control evaluates against the source, and there the logical name is the right one. Mixing the two rules is the most common mistake.
Distinctdoes not delegate in Dataverse (references/dataverse-delegation.md); the example is only about the name. On a large table the list of values comes from a domain table or a flow.
5. Data source name and primary key
- The data source name in the app is the name the table was added with in the app's data
pane — normally the table's display name, but it can come with an alias (singular/plural) different
from the table's. Read the data pane, do not assume.
[verified: reference projects] - A name with a hyphen, a space or starting with a digit requires single quotes:
'pedidos-unidade'. Single quotes inside the name are doubled ('o''brien'). - The primary key (
PrimaryIdAttribute,<table>id) has the table's own name as its display name. In a formula this collides and needs quotes:varPedidoSel.'pedidos-unidade'returns the GUID. When sending the GUID to a flow, convert it withText(...).[verified: reference project] - The primary name (
PrimaryNameAttribute) is required on every table and is the label Dataverse uses in grids and Lookups — it is not necessarily the "descriptive" column the screen shows.
6. Choice, Lookup, text, Yes/No: what changes
Official type mapping of the connector (Dataverse → Power Apps): Choice and Yes/No → Choice; Date and time and Date only → DateTime; Whole number/Decimal/Float/Currency → Number; Single line of text, Email, URL and Multiple lines of text → Text; Unique identifier → Guid (source).
6.1 Choice
The Choice's name in Power Fx is '<column> (<table>)'; the options are properties of it.
[verified: reference project]
Destination: Studio formula bar in en-US locale (, and ;).
// Filter by a known option
Filter(Pedidos, situacao = 'situacao (Pedidos)'.Aberto)
// Filter by what the user chose in a ComboBox whose Items is Choices('situacao (Pedidos)').
// Two If branches OUTSIDE the Filter: IsBlank(...) || ... inside the Filter breaks delegation
// (dataverse-delegation.md §4)
If(
IsBlank(cboSituacao.Selected),
Pedidos,
Filter(Pedidos, situacao = cboSituacao.Selected.Value)
)
// Write: needs the option RECORD, not the text
Patch(Pedidos, Defaults(Pedidos), { situacao: 'situacao (Pedidos)'.Aberto })
// Display as text
Text(ThisItem.situacao)
Destination: ComboBox properties in the pasted YAML (, between arguments).
Items: =Choices('situacao (Pedidos)')
DisplayFields: =["Value"]
SearchFields: =["Value"]
Points of attention:
- Comparing the Choice with
.Selected(a record) fails;.Selected.Valueworks whenItemscomes fromChoices(...). Comparing with a literal text (situacao = "Aberto") does not compile.[verified: reference project] - Writing text to a Choice does not compile: use the option object, or a
Switchthat translates the label into the option. - Delegation:
=and<>delegate on Choice;<,<=,>,>=andIsBlankdo not (Learn). For "no value", note 9 of the official table acceptscol = Blank()in general, but the Choice row marksIsBlankas not delegable: testsituacao = Blank()withData row limit = 1before relying on it[unverified]. Choices(...)does not delegate and returns the list of options: it serves a ComboBox, not a large table.- If the column is not a Choice in the environment,
Choices()does not exist for it and the domain lives in the app (a literal table inItems) — see §7. - A global Choice shares the options across tables; the name in Power Fx remains
'<column> (<table>)'. [unverified] whether the name changes to a plain global one in every environment. - Integer values of the options: Dataverse prefixes them per publisher (e.g.
<n>0000001). Do not assume1, 2, 3in a load CSV or in a contract with an external system; read the environment's options (GlobalOptionSetDefinitions(Name='…'), seereferences/as-built-names.md).
6.2 Lookup
// formula bar (en-US: , and ;)
// Compare with the record
Filter(Pedidos, cliente = varClienteSel)
// Write: pass the record
Patch(Pedidos, Defaults(Pedidos), { cliente: LookUp(Clientes, nome = "Customer A") })
// Read a field of the related record
ThisItem.cliente.nome
[unverified in the environment]: the reference projects swapped every Lookup for text/Choice
before writing these formulas; the syntax above is the documented one for Lookup, with no field
evidence. Cautions that hold regardless:
- Filtering by a column of the related table (
cliente.nome = "X") forces a join on the server. The connector's structural limits (lookup levels, entities per query) are inreferences/dataverse-delegation.md. For a hot filter, denormalize: copy the column to the child table as text (references/modeling.md). DefaultSelectedItemswants rows from the same source asItems;Table(<text>)does not work.[verified: reference project]
6.3 Text that stores a code (the "fake lookup")
A text column that stores the abbreviation, name or code of another table. It compares text with text:
// formula bar (en-US: , and ;)
Filter(Pedidos, unidade = cboUnidade.Selected.sigla) // Selected.sigla, not Selected
ThisItem.unidade // already text
It delegates like any text equality. What is lost: referential integrity (an invalid
value gets in, a homonym collides) and the automatic join. See references/modeling.md.
6.4 Yes/No
ativo = true works and delegates; 'ativo (Pedidos)'.Yes also exists (the en-US label). Prefer
true/false. [verified: reference project]
6.5 Date
DateOnly and DateAndTime map to DateTime. A direct date filter delegates in Dataverse, except
Now() and Today() applied as a date function (note 3 of the official table, in conflict with the delegation
page; see references/dataverse-delegation.md): compute the date in a variable first. Unlike
the SQL connector, where a direct date does not delegate behind a gateway (default-decisions.md B2).
7. Decision table by type
Real type (AttributeType) |
Compare | Write | ComboBox Items |
Attention |
|---|---|---|---|---|
Picklist (Choice) |
col = 'col (Table)'.Option or col = cbo.Selected.Value |
option object | Choices('col (Table)') |
</IsBlank do not delegate |
Boolean (Yes/No) |
col = true |
true/false |
— | — |
Lookup |
col = record |
record (LookUp/.Selected) |
Filter(TargetTable, …) |
filtering by a column of the related table: denormalize |
String storing a code |
col = cbo.Selected.<column> |
text | domain table or literal | no integrity; the domain lives in the app |
String storing a fixed domain |
col = "Text" |
text | ["A", "B"] (exposes Value) |
the domain lives on the screen; nothing stops the flow from writing outside it |
Integer/Decimal |
col = n |
number | — | arithmetic on the column does not delegate |
DateTime |
col >= dateVar |
date | — | Today()/Now() in a variable |
Uniqueidentifier |
col = GUID(...) |
— | — | Text(...) when sending to the flow |
The question that decides the syntax is always the same: what is this column's AttributeType in the
as-built? If the as-built says ?, the formula is not written until someone reads the type.
Open this reference as its own page
Security in Dataverse: who reads which rows
Security role, business unit, owner team, row scope and column security, with the risk of
Organization scope. Authorization inside the flow belongs to power-automate; the rule that scope
on the screen is UX and not a control is default-decisions.md A3 -- here is what to do in Dataverse
so that the barrier really exists.
Contents
- The model in one table
- Security role and access level
- The risk of Organization scope
- Row isolation: owner team + business unit
- Column security
- Application profile × security role
- How to test outside the app
- Decision and risk record
1. The model in one table
| Piece | What it controls | Granularity |
|---|---|---|
| Security role | Privileges (create, read, write, delete, append, append to, assign, share) per table | Table × access level |
| Access level | Which rows the privilege applies to: User, Business unit, Parent: child, Organization | Row, by owner and by BU |
| Business unit (BU) | Isolation hierarchy: the row's owner belongs to a BU | Tree of units |
| Owner team / access team | A group that can own rows (owner team) or receive access to specific rows (access team) | Set of users |
| Column security | Who reads/writes a specific column (column security profile) | Column |
| Gallery filter | Nothing security-related: only what the screen shows | — |
General source:
Security roles and privileges
and Security concepts in Dataverse.
The detail of behavior per access level and BU inheritance was not reconfirmed here
[unverified]; the practice of the reference projects is recorded in the Script of §4.
2. Security role and access level
- The role says which tables and which verb; the access level says which rows. A role with Read at Organization reads all rows of the table, from all BUs.
- Whoever uses the app needs a role with the privileges of the tables the app touches, including Append/Append to on the tables related by Lookup (to write a Lookup).
- Least-privilege principle: domain tables (catalogs, profiles) on Read; transactional ones with
Create/Read/Write; Delete off when the business does not delete (it uses
ativoor the "closed" state). A second role (administration) with Create/Write on the user and link tables, assigned only to whoever has the matching application permission. - The role is assigned to the user or to a team; the Entra group that provisions access is the same one the provisioning flow manipulates: agree on the group name before creating the role.
- A flow's service connector runs as the connection's account, not as the app user: that
account's role decides what the flow can read (
power-automate).
3. The risk of Organization scope
A security role at Organization scope on the app's tables limits which tables the user accesses,
not which rows. Effect: any user with access to the environment and the role can read the whole
table -- all units -- through Excel, Power BI, the Web API (OData) or any other
Dataverse client, regardless of what the app's gallery shows.
[verified: reference project] -- risk formally accepted for time and cost reasons.
Points the team tends to underestimate:
- The unit filter in the gallery helps navigation; the server is what blocks. The screen can be bypassed.
- "Only whoever has the app" is not a barrier: the role gives access to the table, not to the app.
- This is a reduction in security compared with an architecture where only the application talks to the database (SQL Server with a service account and procedures).
- Power BI and Excel over Dataverse read with the identity of whoever queries and inherit the same problem.
If the operation does not need real isolation (the units already see each other; the filter is a convenience), Organization scope is a legitimate choice -- as long as it is recorded as an accepted risk (§8). If it does, go to §4.
4. Row isolation: owner team + business unit
Recommendation for real isolation per unit: Owner Teams + Business Unit. Script
([verified: reference project] as a plan and estimated cost; not executed, by decision):
- Define the granularity. One BU/owner team per region (few) is viable. One BU per unit (dozens) costs a lot of administration and was discarded in the reference project; isolating unit from unit within the same region requires one BU per unit.
- Create the Owner Teams (one per isolation unit) and link each to its BU.
- Change the role's access level from Organization to Business unit (or Parent: child, if the region sees its units).
- Assign each row's
owneridto its unit's team, at write time -- through the registration flow, which knows the row's unit. Tables that will undergo this isolation must be born UserOwned (seereferences/modeling.md): a table's ownership type cannot be changed after it is created[unverified: a claim from a creation script; check Learn before relying on it]. - Keep the screen filter, now as a convenience, not as a control.
- Test outside the app (§7).
Costs and risks:
- A row without the right owner is invisible (or too visible): the flow that assigns
owneridbecomes the critical point. Imported legacy rows must receive the right owner on load (references/data-import.md). - A user who serves more than one unit needs more than one team.
- Shared domain tables (unit catalog, profiles) stay OrganizationOwned with Read at Organization -- they are not isolated.
5. Column security
To hide one column (sensitive data inside a table everyone reads), use column-level security: mark the column as protected and grant a column security profile to whoever reads/creates/updates.
- It protects against direct reading through the API, unlike hiding the field on the screen.
- It does not isolate rows; combine with owner team/BU when the requirement is per unit.
- A protected column appears as empty/blocked to whoever does not have the profile: a formula that depends on it
must handle
Blank(). [unverified]: exact behavior of a protected column in a Canvas formula and in Power BI.
6. Application profile × security role
They are different layers and do not replace each other:
| Application profile | Security role | |
|---|---|---|
| Where it lives | App table (perfis + pode_x flags) |
Dataverse |
| Who enforces it | The app and the flow | The server |
| Bypassed from the client? | Yes, if only the app enforces it | No |
| Used for | Showing/hiding a button; per-action flag in the flow | Blocking access to the data |
Permission by profile flag (pode_x), never by profile name (T8); no resolved profile = no
access (fail-closed). The flag decides what the app offers and what the flow accepts; the role decides what
the data hands to whoever queries it by another path. If only the flag exists, the control belongs to the app.
7. How to test outside the app
The test that isolation exists cannot be done through the screen. With a test account that has only the app's role and belongs to another unit:
GET https://<org>.crm.dynamics.com/api/data/v9.2/<EntitySet>?$select=<coluna>&$top=50
(through the browser authenticated as that account, or through Excel/Power BI connected to Dataverse with it). Expected result: only rows of that account's unit. Returning rows from other units = effective Organization scope. Record the command, the account used (no personal data) and the date.
Do the same for writing (try to update a row from another unit) and for the protected column.
8. Decision and risk record
Choose and write it in the project's ADR (default-decisions.md A3/A4):
| Situation | Decision | Record |
|---|---|---|
| Units already see each other; the filter is a convenience | Organization scope | Formal accepted risk: "any user with the role reads all units through Excel/Power BI/Web API", with owner and date |
| Isolation per region required | Owner Teams + BU | Plan for assigning ownerid in the registration flow and on load |
| Isolation per unit required | Reassess the track (SQL + procedures with authorization in the flow) or a BU per unit | ADR with the administration cost |
| Sensitive column | Column security | Profile and the list of who receives it |
Never: a gallery filter as the only control with no recorded risk; Power BI over Dataverse with Organization scope without addressing the risk.
More in this playbook
Safe to turn on
Use this skill when an agent or person is about to create, change or enable an automation inside someone else's account or a shared environment: "create this workflow", "build it in the customer's account", "turn it on", "go live", "deploy this automation". Produces a proposal the human approves, an automation created in the off state, and a short list of what only the human can finish.
Workflow buildingMITn8n agents
Design n8n AI agents the right way. Use when building or editing any @n8n/n8n-nodes-langchain.* AI node — an AI Agent, LLM chain, Text Classifier, or Information Extractor — and whenever the user mentions AI agents, LLM with tools, tool calling, $fromAI, system prompts, agent memory, sessionId, structured/JSON output, output parser, RAG, vector store, a chat assistant/bot, or human-in-the-loop review. Covers Agent-vs-chain-vs-classifier choice, the model/memory/tools/outputParser slots, tool names/descriptions as prompt, structured output with autoFix, memory, RAG, human review, and chat topologies.
Workflow buildingMITn8n agents
Design n8n AI agents the right way. Use when building or editing any @n8n/n8n-nodes-langchain.* AI node — an AI Agent, LLM chain, Text Classifier, or Information Extractor — and whenever the user mentions AI agents, LLM with tools, tool calling, $fromAI, system prompts, agent memory, sessionId, structured/JSON output, output parser, RAG, vector store, a chat assistant/bot, or human-in-the-loop review. Covers Agent-vs-chain-vs-classifier choice, the model/memory/tools/outputParser slots, tool names/descriptions as prompt, structured output with autoFix, memory, RAG, human review, and chat topologies.

