How to group by or get top in fetchXML

There are a lot of comments on a ticket in my system. Ticket and comment are in separate entities. There is a field name modifyon in the Comment entity to define when the comment created.

How can I get just latest comment for each ticket?

Example:

Upvotes: 0

Views: 995

Answers (1)

We cannot do subquery in fetchxml to get the latest or last modifiedon record from child linked entity.

Normally we will have a flag in child record to identify or keep a lookup of latest record in parent, so its easy to pull/filter/expand whenever need comes.

You can try start querying from the child entity (comments) and inner join the parent case to achieve what you want.

Upvotes: 1

Related Questions