Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

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++;

Posted

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

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.

Posted

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.

This topic is 4962 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.