Klevr Product Documentation logo

Klevr FetchXML Filter Builder

The FetchXML Filter Builder is a web resource that provides a better interface for creating FetchXML queries.

Feature Overview

The FetchXML Filter Builder is a web resource that provides a better interface for creating FetchXML queries. It automatically loads entity metadata from your Dataverse environment and generates properly formatted FetchXML that can be copied, validated, and used in plugins, workflows, or other customizations.

Features

  • Visual Query Building - Build queries without writing XML
  • Entity Browser - Browse all entities with Advanced Find enabled
  • Field Selection - Select specific columns to retrieve
  • Multiple Operators - Support for 20+ filter operators
  • Nested Groups - Create AND/OR filter groups
  • Related Entities - Join up to 10 related entities
  • Nested Joins - Support for multi-level relationship traversal
  • Import FetchXML - Load and edit existing queries
  • Validation - Test queries against Dataverse before use
  • D365 Integration - Auto-save to form fields when embedded

Design Details

Getting Started

Standalone Usage

2
Load Entities

The utility will automatically load available entities from your environment.

3
Select an Entity

Select an entity to begin building your query.

Embedded in a D365 Form

Add the web resource to a form with the following custom parameter to enable auto-save:

fieldname=your_fetchxml_field

This will automatically load existing FetchXML from the field and save changes back to it.

Data Source

The Data Source section is the first configuration area in the Filter Builder and controls the fundamental "what" of your query:

Design Details (1)

Design Details (1)
FieldDescription
EntityThe primary entity for your query. Use the search box to filter entities. Note: Changing the entity clears all filters, columns, and related entities
Columns to RetrieveSelect specific attributes to return. Leave empty for <all-attributes />.
<!-- No columns selected -->
<fetch>
  <entity name="account">
    <all-attributes />
    ...
  </entity>
</fetch>

<!-- Specific columns selected -->
<fetch>
  <entity name="account">
    <attribute name="name" />
    <attribute name="accountnumber" />
    <attribute name="revenue" />
    ...
  </entity>
</fetch>

Filter Conditions

The Filter Conditions section is where you build the WHERE clause of your FetchXML query. It uses a visual rule-based interface where each condition consists of three parts: a Field (the attribute to filter on), an Operator (like Equals, Contains, Is Null, etc.), and a Value (the comparison value, which is hidden for null-check operators). The section supports AND/OR logic via toggle buttons at the group level, allowing you to specify whether all conditions must match (AND) or any condition can match (OR). You can create complex logic by adding nested groups — child filter groups that can have their own AND/OR operator, enabling queries like "(name contains 'test' AND revenue > 1000) OR statecode = Active". The value input adapts to the field type automatically: text fields show a text box, dates show a calendar picker, lookups show a searchable record dropdown (fetching up to 5,000 records), and booleans show a checkbox. If you have linked entities with aliases, an additional Entity dropdown appears allowing you to reference fields from joined tables using the entityname attribute in FetchXML. A badge in the header shows the total condition count across all groups and linked entities.

Design Details (2)

Design Details (2)

Usage

1
Click Add Condition

Click Add Condition to add a new rule.

2
Select a Field

Select a Field from the dropdown.

3
Choose an Operator

Choose an Operator (operators available depend on field type).

4
Enter a Value

Enter a Value (if required by the operator).

Available Operators

OperatorLabelRequires ValueField Types
eqEqualsYesAll
neNot EqualsYesAll
likeContainsYesString
not-likeDoes Not ContainYesString
begins-withBegins WithYesString
ends-withEnds WithYesString
ltLess ThanYesNumber, DateTime
leLess Than or EqualYesNumber, DateTime
gtGreater ThanYesNumber, DateTime
geGreater Than or EqualYesNumber, DateTime
inInYes (multi)String, Lookup, OptionSet
not-inNot InYes (multi)String, Lookup, OptionSet
nullIs NullNoAll
not-nullIs Not NullNoAll
todayTodayNoDateTime
yesterdayYesterdayNoDateTime
tomorrowTomorrowNoDateTime
this-fiscal-yearThis Fiscal YearNoDateTime
last-fiscal-yearLast Fiscal YearNoDateTime
next-fiscal-yearNext Fiscal YearNoDateTime

AND/OR Logic

Use the toggle buttons to switch between:

  • AND - All conditions must match
  • OR - Any condition can match

Related Entities (Joins)

The Related Entities section allows you to join data from related tables using FetchXML's <link-entity> element. When you click Add Join, a card appears where you configure the relationship: select the Related Entity (defaulting to entities with known relationships, with a "Show All" toggle to see every entity), choose a Relationship from the auto-discovered OneToMany, ManyToOne, or ManyToMany relationships (or select "Custom" for manual configuration), and the From/To attributes auto-populate based on the selected relationship (From = the related entity's join field, To = the main entity's field). You can set the Join Type to Inner Join (only matching records) or Left Outer Join (all records), and the Data Existence dropdown provides a powerful "Does Not Contain Data" option that generates an outer join with a null-check filter to find records without related data (e.g., accounts with no contacts). Each linked entity automatically receives an Alias (aa, ab, ac...) which enables cross-entity filtering in the main Filter Conditions section. Within each join card, you can select Attributes to include from the related table and add Filters specific to that entity. The section supports nested joins up to 10 levels deep via the "Add Nested Related Entity" button, allowing multi-hop relationship traversal (e.g., Account → Contact → Email). A badge in the header shows the current count against the maximum limit of 10 total link entities.

Design Details (3)

Design Details (3)
SettingDescription
Related EntityThe entity to join. Toggle "Show All →" to see all entities. Otherwise it will look at Related Entitys.
RelationshipPre-defined relationship or "(Custom - Manual Selection)".
FromThe attribute on the related entity (usually the primary key or lookup field).
ToThe attribute on the parent entity to match against.
Join TypeInner Join (only matching) or Left Outer Join (all records).
Data ExistenceContains Data or Does Not Contain Data (for exclusion queries).
AliasAuto-generated alias (e.g., aa, ab). Used for cross-entity filtering.

Adding Filters to Related Entities

Each related entity can have its own filter conditions:

2
Add a Filter Condition

Click Add a filter condition in the Filters section.

3
Configure the Condition

Configure conditions just like the main entity.

Generated FetchXML

The bottom section displays the generated FetchXML in real-time:

  • Validate - Test the query against Dataverse. Will popup a menu with the returned results of the fetchxml.
  • Copy - Copy the FetchXML to clipboard.

Design Details (4)

Design Details (4)

Manually Importing FetchXML

1
Click Import FetchXML

Click Import FetchXML in the header.

2
Paste FetchXML

Paste your existing FetchXML into the text area.

3
Load the Query

Click Import & Load.

The utility will:

  • Parse the XML and extract entity, attributes, filters, and joins
  • Load metadata for all referenced entities
  • Populate the UI with the parsed query
  • Show a success message with counts

Design Details (5)

Design Details (5)

Last updated on