I have a requirement to get randomly display testimonial content based on custom tagged criteria. There could potentially be nearly 5-10 components that match the criteria. I have used CustomMetaValueCriteria along with ItemTypeCriteria, PublicationCriteria among others to get my required itemURIs. Example below.


Is there a way that I can mention a custom random sort criteria (to get 1-10, 2-10 .. 10-10) based on the number of tagged components? It does look like the sort criteria is something that needs to be build once the base query is executed and the list is available in the web application but I am trying to evaluate OOTB options, if it is an option. We are using Site 9.1 and a non-DXA web application.

  • 1
    If I understand you correctly, you think you'll probably just have to sort the resulting list yourself, but you want to check if there's a built-in feature you can use instead. I'd say picking one out of 5-10 CPs that match your criteria is work for you, not the API. If you truly want a random pick, the IDs should be sufficient, so it's not heavy. Dec 5, 2021 at 8:38
  • 1
    I did similar functionality recently, there is no API to return randomly. we got the result of 5 item Ids and did ourself random within the results to display 1 item id component data.
    – Velmurugan
    Dec 6, 2021 at 11:53
  • Thanks Dominic and Velu. I will keep the question open for a couple more days for more feedback and close it with relevant findings. Thank you!
    – Shiva
    Dec 6, 2021 at 16:00

1 Answer 1


We've tried this and it's not possible OOTB.

You will need to retrieve the ID and any relevant data you wish to base the random selection on and then randomize and request from within your app.

  • In our example we got the last updated 50 items
  • we selected the last 50 items as there were actually thousands of items so we agreed a first-level (OOTB filter) with the business
  • we then applied the radnmizer in the app which returned 5 IDs
  • we requested and displayed the randomized items

As an extra - we actually tracked what had been selected to validate our randomizer was indeed returning items a relatively similar amount of times overlall.

  • Thanks Dylan. It would be a good enhancement since it is a pretty common requirement if we are using a lot of content tagging with Sites 9.5/6.
    – Shiva
    Dec 17, 2021 at 15:51
  • 1
    I like the idea (and perhaps you should consider adding something with detail in Tridion Ideas? I would say - you'd need to consider what you would expect to be configurable/default; I've seen several sets of requirements for this that are, on the face of it, similar but when you drill down into detailed requirements often then include very specific business requirements that preclude simply reusing a previous implementation. Dec 20, 2021 at 8:43

Your Answer

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

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