Repeating Fields

Support for repeating fields was first added in version 3.

Repeating fields are formatted as: fieldName[numericalIndex]

FileMaker script would start numericalIndex at one (1). The FileMaker PHP API starts numericalIndex at zero (0), RESTfm uses this same zero-based indice convention for maximum compatibility with other web services. Please be aware of the difference in mapping.

Example READ for a record with repeating fields data

{
    "data": [
        {
            "Comment": "Repeating field example. Max repeat is 5. Layout set to show 1 to 3.",
            "Repeating[0]": "red",
            "Repeating[1]": "green",
            "Repeating[2]": "blue",
            "Repeating[3]": "",
            "Repeating[4]": ""
        }
    ],
    "meta": [
        {
            "recordID": 1,
            "href": "\/RESTfm\/RESTfmUnitTests\/layout\/RepeatingFields\/1.json"
        }
    ],
    "metaField": [
        {
            "name": "Comment",
            "autoEntered": 0,
            "global": 0,
            "maxRepeat": 1,
            "resultType": "text"
        },
        {
            "name": "Repeating",
            "autoEntered": 0,
            "global": 0,
            "maxRepeat": 5,
            "resultType": "text"
        }
    ],
    "info": {
        "X-RESTfm-Version": "3.0.0alpha\/UNKNOWN",
        "X-RESTfm-Protocol": "4",
        "X-RESTfm-Status": 200,
        "X-RESTfm-Reason": "OK",
        "X-RESTfm-Method": "GET"
    }
}

Example data for CREATE/UPDATE of a single repeating field

{
    "data": [
        {
            "Repeating[2]": "orange"
        }
    ]
}
This is valid POST/PUT data if, and only if, the layout is set to show this repetition.

Warning

A  layout may be configured to show a sub-range of repetitions. RESTfm is unable to identify this information from the API provided by FileMaker. Only the 'Maximum number of repetitions' is known. RESTfm will always attempt to read the value of all repetitions of a field, but some may return empty if they are not shown on the layout. Attempting to modify a repeating field that is not shown in a layout will result in FileMaker error:  102 Field is missing.
{
    "data": [
    ],
    "meta": [
    ],
    "info": {
        "X-RESTfm-FM-Status": "102",
        "X-RESTfm-FM-Reason": "Field is missing",
        "X-RESTfm-Version": "3.0.0alpha\/UNKNOWN",
        "X-RESTfm-Protocol": "4",
        "X-RESTfm-Status": 500,
        "X-RESTfm-Reason": "FileMaker Error",
        "X-RESTfm-Method": "put"
    }
}

Example error when attempting to update a repetition that is within maxRepeat range, but not displayed in the layout.

When working with field repetitions it is recommended that a layout, with all repetitions visible, is used for access via RESTfm.

Changelog

Version Description
3.0.0 Added support for repeating fields.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us