ManyToManyLookupEdit

The ManyToManyLookupEdit component provides an inline autocomplete editor for managing many-to-many (N:N) relationships between Dataverse records. It displays the currently associated records as chips and allows users to search, add, and remove associations without navigating away from the form.

How It Works

Place the component inside a RecordContext and specify the RelationshipName. The component automatically resolves the related table, loads associated records, and provides a searchable autocomplete dropdown for adding new associations.

<RecordContext TableName="account" QueryParameterName="id">
    <ManyToManyLookupEdit RelationshipName="ppp_Account_ppp_Region_ppp_Region" />
</RecordContext>

Views

Use ViewIds and DefaultViewId to control which views are available for searching related records. The view's columns are displayed in the dropdown to help users identify the correct record. If no views are specified, the default public view for the related table is used.

<ManyToManyLookupEdit RelationshipName="ppp_Account_ppp_Region_ppp_Region"
                      ViewIds="_regionViews"
                      DefaultViewId="@(new Guid("..."))" />

@code {
    private List<Guid> _regionViews = new List<Guid>
    {
        new Guid("..."),
        new Guid("..."),
    };
}

Validation

Use MinimumNumberOfItems and MaximumNumberOfItems to enforce constraints on the number of associated records. Setting a minimum automatically marks the field as required.

<ManyToManyLookupEdit RelationshipName="ppp_Account_ppp_Region_ppp_Region"
                      MinimumNumberOfItems="1"
                      MaximumNumberOfItems="3" />

Saving

Changes are tracked as pending associate and disassociate requests. When the parent MainContext is saved, these requests are included in the transactional save operation alongside any other record changes.

<MainContext>
    <MenuBar>
        <SaveContextButton />
    </MenuBar>

    <RecordContext TableName="account" QueryParameterName="id">
        <ColumnEdit ColumnName="name" />
        <ManyToManyLookupEdit RelationshipName="ppp_Account_ppp_Region_ppp_Region"
                              MinimumNumberOfItems="1"
                              MaximumNumberOfItems="3" />
    </RecordContext>
</MainContext>

Example

The following example shows a basic ManyToManyLookupEdit bound to a many-to-many relationship.

Blazor example
React example

Configuration Options

Use the controls below to explore the ReadOnly, Disabled, MinimumNumberOfItems, and MaximumNumberOfItems properties.

Blazor example
Readonly? Disabled?
React example
Blazor

ManyToManyLookupEdit Class

Parameters

Name
Type
Default
Description
ChildContentRenderFragment?
Child content of the component
ContextMainContext?
Cascading context that registers this editor for coordinated save operations.
DefaultViewIdGuid?
Specifies which view should be used as the default when browsing related records.
Descriptionstring?
Description to be displayed in the tooltip.
Disabledbool?
Should the editor be disabled.
DisplayLabelWhenAvailablebool
True
Specifies whether to display a lable if available.
DisplayTooltipWhenAvailablebool
True
Specifies whether to display a tooltip if available.
DisplayValidationErrorMessagebool
True
Should a validation error message be displayed when the component fails validation?
IsDirtybool
False
Gets a value indicating whether there are pending association or disassociation changes that have not yet been saved.
IsVisiblebool
True
Is the editor visible.
Labelstring?
Text to be displayed as a label for the editor.
MaximumNumberOfItemsint?
Maximum number of related records that may be selected.
MaxRecordsReturnedint
20
Maximum number of records returned from Dataverse when searching for related records.
MinimumNumberOfItemsint?
Minimum number of related records that must be selected for the editor to be considered valid.
ReadOnlybool?
Should the editor be read-only.
RelationshipName*string
The Dataverse many-to-many relationship name that this editor manages.
Requiredbool?
Should the value be required.
ViewIdsList<Guid>?
Limits which views are available for browsing related records; if empty, the default public view is used.
Name: ChildContent
Type: RenderFragment?
Description: Child content of the component
Name: Context
Type: MainContext?
Description: Cascading context that registers this editor for coordinated save operations.
Name: DefaultViewId
Type: Guid?
Description: Specifies which view should be used as the default when browsing related records.
Name: Description
Type: string?
Description: Description to be displayed in the tooltip.
Name: Disabled
Type: bool?
Description: Should the editor be disabled.
Name: DisplayLabelWhenAvailable
Type: bool
Default: True
Description: Specifies whether to display a lable if available.
Name: DisplayTooltipWhenAvailable
Type: bool
Default: True
Description: Specifies whether to display a tooltip if available.
Name: DisplayValidationErrorMessage
Type: bool
Default: True
Description: Should a validation error message be displayed when the component fails validation?
Name: IsDirty
Type: bool
Default: False
Description: Gets a value indicating whether there are pending association or disassociation changes that have not yet been saved.
Name: IsVisible
Type: bool
Default: True
Description: Is the editor visible.
Name: Label
Type: string?
Description: Text to be displayed as a label for the editor.
Name: MaximumNumberOfItems
Type: int?
Description: Maximum number of related records that may be selected.
Name: MaxRecordsReturned
Type: int
Default: 20
Description: Maximum number of records returned from Dataverse when searching for related records.
Name: MinimumNumberOfItems
Type: int?
Description: Minimum number of related records that must be selected for the editor to be considered valid.
Name: ReadOnly
Type: bool?
Description: Should the editor be read-only.
Name: RelationshipName*
Type: string
Description: The Dataverse many-to-many relationship name that this editor manages.
Name: Required
Type: bool?
Description: Should the value be required.
Name: ViewIds
Type: List<Guid>?
Description: Limits which views are available for browsing related records; if empty, the default public view is used.

Methods

Name
Parameters
Type
Description
GetRequestsList<OrganizationRequest>
Returns the pending Requests.OrganizationRequest operations (associate and disassociate) that must be executed to persist the current selection.
GetValidationErrorsList<string>
Returns validation errors for the current selection, including violations of minimum and maximum item count rules.
RefreshAsyncbool forceRefresh
Task
Instructs the grid to re-fetch and render the current data from the supplied data source.
ResetStatevoid
Clears all pending association and disassociation changes, resetting the editor to its last saved state.
Validatebool
Returns true when the current selection satisfies the configured minimum and maximum item count constraints.
Name: GetRequests
Type: List<OrganizationRequest>
Description: Returns the pending Requests.OrganizationRequest operations (associate and disassociate) that must be executed to persist the current selection.
Name: GetValidationErrors
Type: List<string>
Description: Returns validation errors for the current selection, including violations of minimum and maximum item count rules.
Name: RefreshAsync
Parameters: bool forceRefresh
Type: Task
Description: Instructs the grid to re-fetch and render the current data from the supplied data source.
Name: ResetState
Type: void
Description: Clears all pending association and disassociation changes, resetting the editor to its last saved state.
Name: Validate
Type: bool
Description: Returns true when the current selection satisfies the configured minimum and maximum item count constraints.
React