Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Pulling Random record with specific criteria

Featured Replies

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?

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.

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....

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.