-
Notifications
You must be signed in to change notification settings - Fork 2
FetchXML Generator
Run and edit the FetchXML that is already in your C#, TypeScript or JavaScript. A CodeLens appears above the query, runs it against your environment, and opens a visual generator that writes your edits back into the same string literal.
Preview feature. Tick Preview features in the panel footer to switch the query tools on.
Open a file containing FetchXML. A lens appears above the literal: Run, Edit in generator, and an issue count when there is something to check.

Recognised without any configuration:
| Language | Forms |
|---|---|
| C# | verbatim (@"…"), interpolated ($@"…"), raw ("""…"""), and + concatenation |
| TypeScript / JavaScript | template literals, quoted strings, and + concatenation |
Click the issue count to see the details. Any value your code interpolates into an attribute is flagged so
you can check it is escaped — a quote or an & in the value would otherwise break the query:

Click Run. Anything your code interpolates into the query is a placeholder, and you are asked for a value before the query runs:

The expected type comes from the column in the condition, so a Uniqueidentifier column rejects anything
that is not a GUID and a whole-number column rejects text.
Results open beside your code, with the row count and the environment and user the query ran as. Your
query runs as you here, so row-level security and eq-userid may resolve differently at runtime.

Use Copy as CSV, Copy as JSON or Copy FetchXML along the bottom.
Click Edit in generator.

| Area | Use |
|---|---|
| Tree | Select an element to edit it; add and remove entities, attributes, filters, conditions and links from the controls beneath |
| Properties | The attributes the selected element supports, each with what it does and what it cannot be combined with |
| FetchXML | The query as it currently stands |
| Parameters | Your placeholders, named after the variables in your code |
Run runs the edited query without changing your file. Reload metadata re-reads tables and columns after a schema change. Copy FetchXML puts the query on the clipboard.
Save to code rewrites the string literal in place. Your placeholders go back as the code expressions they came from, the rest of the file is untouched, and an edit that changes nothing writes nothing.
Re-open the lens and the generator reads the same query back.
| Consumer | How it takes FetchXML |
|---|---|
| Plug-in / workflow (SDK) |
new FetchExpression(xml) — full FetchXML including aggregates and link-entity |
| Web resource / PCF | Xrm.WebApi.retrieveMultipleRecords(entity, "?fetchXml=" + encodeURIComponent(xml)) |
| Saved view | The view's fetchxml column — no placeholders, a view cannot prompt |
| Lookup filter | A <filter> fragment, not a whole <fetch>
|
| Portals / Power Pages | Liquid {% fetchxml %}
|
The generator flags anything the surrounding consumer cannot accept — an aggregate in a lookup filter, for instance — while you are editing.
| Problem | Fix |
|---|---|
| No lens on a query | Tick Preview features in the panel footer. The text also has to parse as FetchXML — a malformed fragment reports an issue instead |
| "Connect to Dataverse first" | Running needs a live connection; editing does not |
| Tables or columns look stale | Reload metadata in the generator toolbar |
| The prompt rejects your value | The type comes from the column in the condition — check its attribute
|