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

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

Recommended Posts

Posted

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

Posted

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.

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