I am trying to figure out how to retrieve the latest modified X number of components from a given publication and I've been staring at the Core Service API for ages trying to figure it out. Help!

The best I got is to latch on to the ModifiedAfter and/or ModifiedBefore search parameters in the SearchQueryData class.

So here is what I got so far for my filter:

        var filter = new SearchQueryData { ItemTypes = new[] { ItemType.Component }, SearchInSubtree = true };
        if (!string.IsNullOrEmpty(publicationId))
            filter.FromRepository = new LinkToRepositoryData() { IdRef = publicationId };

        if(resultLimit > 0)
            filter.ResultLimit = resultLimit;

All I need is a Sort Parameter property like on the CD side. Grrr!

Can anyone please suggest a solution?

  • 2
    My General rule of thumb with the Core Service/TOM.NET API is: If it isn't possible in the GUI, then its probably not easy to do with the core service... As you can't pre-define a sort on a search query in the GUI I guess you are out of luck
    – Will Price
    Sep 19, 2014 at 8:33

2 Answers 2


I suspect the best you can use is use the ModifiedAfter and ResultLimit do so something like:

  • Get results from last month
  • Take the top 5 from those
  • If the list is less than 5 from last month, either live with it, or query again ?

Depending on the expected volume of updates this might be a solution for you, but i'd love someone to correct me on it too cause this is a bit of a hacky solution

  • The problem with specifying the ResultLimit is that Tridion doesn't always give you the latest dated items within that limit. What you get is the first X (e.g. 5) that it returns, which is in alphanumeric order just like in the GUI. I think a blended approach between what you're suggesting regarding ModifiedAfter (to limit the resultset to a date) and what Chris proposed (to get the sorted top x results) would work best; though I got lazy and implemented it using ResultLimit anyways. Sep 22, 2014 at 19:01

This is not possible via CoreService.

In conjunction with John's suggestion, you could further limit the results set by restricting the search with additional filters like folder using:

filter.SearchIn = new LinkToIdentifiableObjectData { IdRef = folderId };

Then sort the results locally like

foreach (var item in items.OrderByDescending(x=>x.VersionInfo.RevisionDate.Value))

As Will mentions, if you do a search in the GUI all sorting is done client side

  • 1
    +1 for showing some sexy sorting linq code, and for the suggestion. In my instance the scope is latest content within a Publication, so the folder-based approach won't work, and getting all the items out of a pub and then sorting would require a pretty heavy web service response. Sep 22, 2014 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.