October 24, 201312 yr LS, This must be so simple, but don't get php and how it works not very well with php ( using newAddRecord and execute ). I have created a new record and set data in that record. The questions I have are : 1. how do I set more data in the same record ? 2. when I create the record can I get the contents of an auto-enter create primary-key field back as a result ? Hope this makes sense ! TIA Joost
October 24, 201312 yr Before you can do #1, you have to do #2 //the part you have now // $newRecord = $fm->newAddCommand('YourLayout'); $newRecord->setField('theField', 'theData'); $result= $newRecord->execute(); // // The part you need to add // $getAllRecords = $fm->newFindAllCommand('YourLayout'); $gotAll = $getAllRecords->execute(); $records = $gotAll->getRecords(); $count = count($records); $lastID = $records[$count - 1]->getField('PK');// your auto entered primary key field $recID = $records[$count - 1]->getRecordId(); Now you can edit that record: $addData = $fm->getRecordById('YourLayout'; $recID); $addData->setField('theOtherField', 'theOtherData'); // etc for other fields $done = $addData->commit(); Note that $recID is not your auto entered ID field; it is FileMaker's internal record ID. Of course, if you are populating the other fields at the same time you create the record, you just keep adding setField commands after the newAddCommand step.
October 24, 201312 yr I moving towards not using any PHP API commands except Perform Script. I'm inclined to just let it all run as FileMaker scripts and only use GetField to pull messages from a one field table.
Create an account or sign in to comment