Dmitriy Razumov
3 posts
Registered:
09 Aug 2024
09 Aug 2024
Link to this post
Hello,
we're having a problem making a query inside a grid. We're making link-entity not to get any attributes from it, but only for applying filters. There are more than one linked records, which results in duplicates in the grid.
Distinct=true doesn't work because TPC automatically includes primary Id for linked records making duplicates distinct. We solved it by applying aggregate fetch, but with aggregate fetch Sorting by columns on the front end is not working, because TPC code probably adds order by attribute, but aggregate requires every attribute to have alias and it results in error "An attribute cannot be specified for an order clause for an aggregate query. Use an alias".
Then we tried link-type='matchfirstrowusingcrossapply'
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/fetchxml/join-tables?tabs=fetchxml#use-matchfirstrowusingcrossapply-link-type
it works fine if I make request outside TPC (in XrmToolbox FetchXML builder), but TPC grid ignores this instruction which again results in duplicates.
Also, we tried intersect=true with the same result
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/fetchxml/join-tables?tabs=fetchxml#many-to-many-relationships
Could you please tell us what can we do? Is there some flag to use Raw FetchXML in the Grid Model Settings? Or to disable auto-include of linked records Primary Id? Or Is there some event on the server side where I can modify the FetchXML request that's being sent to Dynamics? Or if there's some flag to use aliases instead of attributes for ordering?
Tnank you.