AnsweredAssumed Answered

How to setRecord on portal with PHP?

Question asked by fpeaker on Jul 19, 2016
Latest reply on Jul 20, 2016 by fpeaker

Hi - This is my first time posting. I am new to FM and a novice at PHP.


I can retrieve a record from a portal of a layout, but I can't edit the record. What am I doing wrong? This is driving me nuts. I can get the field data from acct_AGREE::Calc.AgreeStatus, but I can't edit it using setRecord();


# get the record by its id

$record =& $fm->getRecordById($layoutProperties, $recordId);


// Loop through the associate records

foreach ($records as $record) {


    // Display the current associate record

    echo '<div>';

    echo '<table border="1">';

    echo '<tr><th>Account Name</th><td>'.$record->getField('Account Name').'</td></tr>';

    echo '<tr><th>Status</th><td>'.$record->getField('Status').'</td></tr>';

    echo '<tr><th>Type</th><td>'.$record->getField('Type').'</td></tr>';

    echo '</table>';


    // Get the time records related to this associate

    $timeRecords = $record->getRelatedSet('acct_AGREE');


    // Display the time records in a separate table

    echo '<table border="1">';

    echo '<tr>';

    echo '<th>Date</th>';

    echo '<th>Status</th>';

    echo '<th>Description</th>';

    echo '</tr>';

    foreach ($timeRecords as $timeRecord) {

        echo '<tr>';

        echo '<td>'.$timeRecord->getField('acct_AGREE::Season').'</td>';

        echo '<td>'.$timeRecord->getField('acct_AGREE::Calc.AgreeStatus').'</td>';

        echo '<td>'.$timeRecord->getField('acct_AGREE::AgreementType').'</td>';

        echo '</tr>';


    echo '</table>';

    echo '</div>';



$agreeStatus = $timeRecord->getField('acct_AGREE::Calc.AgreeStatus');


Everything above works.  But as soon as try and change the Status record from whatever it is to 'Dead' with the code below, I get a Error 102 - no record found.


//Edit Record

$editCommand = $fm->newEditCommand($layoutProperties, $recordId);

$editCommand->setField('acct_AGREE::Calc.AgreeStatus', 'Dead');

$result = $editCommand->execute();


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

     echo 'unable to find the user records: ' . $result->message . '(' . $result->code . ')';




Any help would be greatly appreciated. Thank you!