SFDonovan Posted November 29, 2010 Posted November 29, 2010 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++;
dansmith65 Posted December 3, 2010 Posted December 3, 2010 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).
SFDonovan Posted April 15, 2011 Author Posted April 15, 2011 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.
dansmith65 Posted April 15, 2011 Posted April 15, 2011 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.
Recommended Posts
This topic is 5227 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 accountSign in
Already have an account? Sign in here.
Sign In Now