Repository navigation
Import N:N relationships from a table to itself - #28
Merged
Merged
Conversation
In a self-referencing N:N relationship the intersect columns are named <table>idone and <table>idtwo. The intersect import worked out each side's table by removing a trailing "id", so it asked for a table called <table>idone and every record failed. TableOfIntersectColumn now removes idone and idtwo as well. Xrm.Utils.Core's Associate already sets PrimaryEntityRole when both sides are the same table, so with the right names the association goes through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An intersect block for an N:N relationship from a table to itself failed on import for every record.
The cause
In a self-referencing N:N relationship the intersect columns are named
<table>idoneand<table>idtwo. The intersect import worked out each side's table by removing a trailingidfrom the column name, so it asked Dataverse for a table called<table>idone:The fix
A small
TableOfIntersectColumnhelper inShuffleDataImportremovesidone,idtwoorid. The rest of the intersect import is unchanged.The other half of the issue - Dataverse needs
PrimaryEntityRoleon an associate for a reflexive relationship - was already handled:Associatein Xrm.Utils.Core setsEntityRole.Referencingwhen both sides are the same table. It just never got that far, because the table names were wrong.Tests
New
IntersectImportTests:PrimaryEntityRole = Referencing. This test fails without the fix: the request went out asnew_categoryidone.accountid/contactid) still resolves toaccountandcontact, without a role.All 274 tests pass in Debug and Release. The README and the Runner and Deployer release notes have a line for it.
Fixes #27