Jump to content

This topic is 7728 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I'm not sure this is possible given the limitation of the FindAny CDML tag but here's what I want to do...

I want to pull a random record from the database but want to include specific criteria about which records to be chosen. Anyone know if this is possible?

Or does anyone know another way other than to use -FindAny?

Posted

It's not really a random record then, is it? wink.gif

Probably what you need to do is perform a -Find for the records you want based on the criteria, then sort them randomly (create an unstored calc field that uses the Random function) and return the first record to the user.

Posted

LOL @ Vaughan

if u look at your criteria as = category then u can use Vaughan's approach. so eg.

pull all the records CATEGORY="shoes" but do NOT sort them by shoe size....is one way of looking at "random record in an ordered group"

I guess it depends what aspect of a record is to be taken as random

(eg. unsorted shoe: size,color,brand name etc.)

Take it away....

This topic is 7728 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.