FileMaker icon indicating copy to clipboard operation
FileMaker copied to clipboard

You can't update certain fields - you have to update all at once.

Open mrchimp opened this issue 8 years ago • 3 comments

Hello! Me again!

If I run an edit command (or a commit on an existing record) and don't set all required fields, I get a FileMakerValidationException with code 0:

FileMakerValidationException in Command.php line 155:
Field name is required
Field code is required
Field category is required

The same thing happens if I do:

$edit = $fm->newEditCommand('SomeLayout', $record_id, ['foo' => 'bar'];
$result = $edit->execute();

...or ...

$rec = $fm->getRecordById('SomeLayout', 6);
$rec->setField('foo', 'bar');
$result = $rec->commit();

The FileMaker API docs don't really specify whether this should work or not but if it doesn't it means a bunch of extra code for each update. Any ideas?

mrchimp avatar Sep 21 '17 14:09 mrchimp

Is turning off the field level validations on those fields in the Define Fields dialog? It sounds like that is preventing the record from being created without those required fields being filled on the initial commit.

This may not be limited to your app. You may not be able to create the record in the same way (piece meal) via a FileMaker UI.

hanzel avatar Sep 23 '17 01:09 hanzel

This is when updating a record, not when creating them - they already exist on FileMaker. The required fields already have data in them.

mrchimp avatar Sep 23 '17 15:09 mrchimp

Hi,

This is the legacy behavior from original PHP API when prevalidate option is activated. I agree this is pretty annoying in some situation such as examples you provide.

As a workaround, you may temporarly disable prevalidation when needed, ie :

$fm->setProperty('prevalidate', false);
$result = $edit->execute();
$fm->setProperty('prevalidate', true);

I will look to find a more elegant way to handle this (I already have some ideas)

airmoi avatar Dec 30 '17 00:12 airmoi