Current Behavior:
When a model-driven app view includes a lookup column that references a virtual entity (such as the Microsoft Entra ID / AAD User table), attempting to sort the view by that column results in a generic SQL error:
SQL error: Generic SQL error. [...]
SQL error 207 means "Invalid column name". This occurs because Dataverse's FetchXML-to-SQL translator generates an ORDER BY clause referencing a companion name column (e.g., cr5a0__ProjectName) that is never created for virtual entity lookups - virtual entities have no physical SQL storage, so the denormalized name column pattern does not apply.
According to current documentation, this is a known platform limitation:
"Although you can add virtual table columns as a lookup on a grid or other UI views, you cannot filter or sort based on this virtual table lookup column."
Requested Improvements:
This idea contains two requests:
1. Enable sorting by virtual entity lookup columns
Users should be able to sort model-driven app views by lookup columns regardless of whether the target table is a physical or virtual entity. The platform could resolve the display name at query time or cache it in a denormalized column to support sorting, similar to how it handles standard lookups.
2. Improve the error message when sorting is not supported
If sorting by virtual entity lookups remains unsupported, the error message should be user-friendly and descriptive rather than exposing a raw SQL error. For example:
"Sorting by this column is not supported because it references a virtual entity. Please sort by a different column."
The current error, "SQL error: Generic SQL error, Sql Number: 207", is confusing, alarming, and provides no actionable guidance. Users and administrators cannot reasonably determine the root cause from this message without deep technical investigation.
Business Impact:
- Lookup columns referencing virtual entities (especially the built-in Microsoft Entra ID table) are common in enterprise environments
- Users expect sorting to work on any visible column in a view
- The current behavior blocks basic usability with no clear indication of why
- The raw SQL error creates unnecessary support cases and alarm
Affected Components:
- Dataverse FetchXML-to-SQL translator (ORDER BY generation)
- Model-driven app view rendering (subgrid sorting)
- Virtual entity metadata integration
- Error handling and user-facing error messages
