Skip to content

Commit fce99ed

Browse files
authored
Merge pull request #84 from gearbox-solutions/2.5-docs
added docs for modId functionality
2 parents a5401d6 + 9a0e337 commit fce99ed

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,28 @@ protected $dateFormat = 'n/j/Y g:i:s A'; // 7/1/1920 4:01:01 PM
265265
protected $dateFormat = 'n/j/Y G:i:s'; // 7/1/1920 16:01:01
266266
```
267267
268+
### Modification ID (modId)
269+
270+
The Data API lets you set a [Modification ID](https://help.claris.com/en/data-api-guide/content/edit-record.html) when editing records.
271+
272+
> Specifying a modification ID ensures that you are editing the current version of a record. If the modification ID value does not match the current modification ID value in the database, the record is not changed.
273+
274+
If you wish to include the modId when editing a record you can call `withModId()` before calling `save()` on the model object. This will send the ModID to FileMaker when updating the record, and will throw a `FileMakerDataApiException` if the ModId does not match.
275+
276+
```php
277+
$person->withModId()->save();
278+
```
279+
280+
The modId is automatically set on the model object when you retrieve a record from FileMaker, so you don't need to set it manually.
281+
282+
283+
If you always want the ModId to be included when saving a record, you can set the `$withModId` property to true on your model class.
284+
285+
```php
286+
protected $useModId = true;
287+
```
288+
289+
If you wish to always include a ModId on a model, you can set `protected $withModId = true;` on your model class.
268290
269291
## Example FMModel Class
270292
```php
@@ -342,7 +364,8 @@ FM::setGlobalFields() // not chainable
342364
->portalLimit( $portalName, $limit )
343365
->portalOffset( $portalName, $startingRecord )
344366
->sort() // alias for the native orderBy()
345-
->omit()
367+
->omit() // change the request to an "omit" request
368+
->modId( string $modId ) // set the modId to submit when editing a record
346369
->fieldData( $array )
347370
->portalData( $array )
348371
```
@@ -395,6 +418,7 @@ $json = json_encode ([
395418
$result = FM::layout('globals')->performScript('New Contact Request'; $json);
396419
```
397420
421+
398422
Perform a script on a database other than the default database connection
399423
```php
400424
$result = FM::connection('MyOtherDatabaseConnectionName')->layout('MyLayoutName')->performScript('MyScriptName');

0 commit comments

Comments
 (0)