countFields

Counts the number of Fields in a List that match the search criteria.

countFields

Counts the number of Fields in a List that match the search criteria.

Top ↑

Syntax

int countFields( string api_key, int list_id [, array search_criteria ] );

Parameters

api_key (string)

The key required to access the API. See Getting Started for more information.

list_id (int)

ID of the List containing the Fields.

search_criteria (array - optional)

An array of search criteria that selects the Fields to be counted. See searchFields for a description of the values that can be searched on.

Return Value

The number of Fields in the List that match the search criteria.

Examples

The following example counts the number of mandatory Fields in List 1234567,

$list_id = 1234567;     // can be obtained using searchLists()

$search_criteria = array(
    array('is_mandatory', 'exactly', '1')
);

$api = new Api($url, 'YOURAPIKEY');
$field_count = $api->invokeMethod('countFields', $list_id, $search_criteria);
{
    "id": 1,
    "method": "countFields",
    "params": [
        "YOURAPIKEY",
        1234567,
        [
            ["is_mandatory", "exactly", "1"]
        ]
    ]
}
{
    "id": 1,
    "result": 4,
    "error": null
}

Error Codes

This method may return the following error codes in addition to the standard error codes:

Code Error Description
303 Unable to Load List list_id is not a valid List
311 Invalid Search Parameter Format search_critera is not valid

See Also