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.

script to determine minimum value in a database

Featured Replies

  • Newbies

I am newbie with FM and I have a very stupid question :

How to create a script wich determines the minimum value in the database for a specific text field ?

I hope with you can help me

You don't need a script, you can use either a Summary field returning the Minimum of the field in the found set or a self join relationship linking all the records and a field calculated as Min(SelfJoin::TheField)

In both cases the formulas apply to *number* fields while your post would appear to point to text field (?)

What exactly IS the minimum value of a text field? Would you consider "," to be a lower value than "*", "%" than "@", "a" than "A", etc.?

-bd

  • Author
  • Newbies

Yes, I mean that "a" is lower than "A, "A" is lower than "B", etc.

For example, I have 5 records in my database Cities

(1) New York

(2) Paris

(3) Brussels

(4) London

(5) San Francisco

The Minimum value in my database should be "Brussels" and the Maximum value should be "San Francisco".. but I can write the script/field because it is not a numeric field

Use the script:

Show All Records

Sort (setup to sort by the field you wish)

Go to Record/Request/Page (first)

Set Field (gFirstOne, Country)

Go to Record/Request/Page (last)

Set Field (gLastOne, Country)

"Country" is the field you wish to find the "minimum" and "maximum" of, gLastOne and gFirstOne are global text fields to provide temporary storage of the first and last values. To differentiate "a" and "A" (if you really need to) you must set the field indexing for Country to ASCII, but then searching for an "a" won't find an "A".

-bd

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.