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.

Getting max(value)

Featured Replies

I have two separate applications with their own databases writing to the same grades layout in a FM database. I need to find the max event_id in the layout so I can increment back at the source. This will provide me with the event_id but will it give me the max event_id?

//Create the 'find all' command and specify the layout

            $findCommand =& $fm->newFindAllCommand('Grades');

            

            //Perform the find and store the result

            $result = $findCommand->execute();

            

            //Check for an error

            if (FileMaker::isError($result)) {

                echo "
Error: " . $result->getMessage() . "";

                exit;

            }

            

            //Store the matching records

            $records = $result->getRecords();

            

            //Retrieve and store the latest event_id in the grade layout

            $record = $records[0];

            $event_id =  $record->getField('event_id');

            $event_id++;

It looks to me like that would give you the value of the 'event_id' for the first record in the found set. If you sorted descending by 'event_id' field, it might work.

You could also create a summary field that equals the max value of 'event_id' field.

Or just let FileMaker increment the field for you, then retrieve the new record's 'event_id' value after creating it (if you need it in your external applications).

  • 4 months later...
  • Author

It looks to me like that would give you the value of the 'event_id' for the first record in the found set. If you sorted descending by 'event_id' field, it might work.

You could also create a summary field that equals the max value of 'event_id' field.

Or just let FileMaker increment the field for you, then retrieve the new record's 'event_id' value after creating it (if you need it in your external applications).

How do I sort? I'm not writing any query at all. Can you explain how I could "create a summary field that equals the max value of 'event_id' field"?

The FileMaker database is not mine, but administered by another department and getting them to do anything is a long process.

I need to find the max event_id in the layout so I can increment back at the source

What do you mean by this?

Is the 'event_id' the primary key field? How is it being populated now? Is it set to auto-enter an incremented value? If so, then you shouldn't have to do anything special when you create a record in that table.

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.