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

Randomly selecting records

Featured Replies

Hi all,

I have a DB containing only about 700 records.

I need to create a script that will do the following

I enter some search criteria and perform the search this will bring back about 70 records on average. Then I run the script.

It gives each found record a number starting at 1 and going up in increments of 1 for each record.

It then generates x number of random numbers not greater in value than the current found count (x = 33% of currentFoundCount)

The random numbers it has generated then relate to the records in the current found set with those numbers

The field "Selected" is then set to "Yes" for these records

The numbers are then removed from the original found set of records

I'm a bit stuck with this one any help would be greatly appreciated!

Thanks

Ed

Before performing the find

Find All

go To Layout [layout with field selected on it]

Replace [selected, "No"]

Your find criteria

After performing find, supposing you have defined an field gRel and relationship SomePercentOfRecs:.gRel-->recNumber

Set field [x,Int(Status(CurrentFoundSet)*33/100)]

Set field [gCounter,x]

freeze Window

if[x]

Loop

Set fiield [gRel,int(random*x)]

If[somePercentOfRecs::Selected="No"]

Set Field [somePercentOfRecs::Selected, "yes"]

Set field [gCounter,gCounter-1]

end if

exit loop if [gCounter=0]

Enter Find Mode[]

Set field [selected, "No"]

Perform Find [Constrain Found Set]

//Handle new found set

end if

Dj

  • Author

Hi Dj,

I've not tried this yet but reading through I'm liking this! Thanks for replying, I'll give it a whirl!

Ed.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.