Customer types
Build the CRM2 customer-types table
/a/CustomerTypes_getDataTable
Query customer types through the shared CRM2 table engine with selected mapped fields, filters, sorting, and paging.
When to use this endpoint
Use CustomerTypes_getDataTable for CRM2’s configurable Customer Types list or another client implementing the shared table-query contract.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.
The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fields | Native array | Yes | Mapped output fields selected from id, name, allowedNext, triggers, lastEdited, and colourHex. Unknown names are ignored and id is always returned. |
isTable | Integer string | No | Defaults to table mode. Exact integer 0 returns only data and permits optional limit. |
draw / start / length | Integer strings | No | Table counter, zero-based offset, and page size; defaults are 0, 0, and 10. No endpoint-specific maximum is imposed. |
limit | Integer string | No | Positive non-table maximum; zero means unlimited. |
orderBy / orderDesc | Mapped name / direction | No | Explicit sort pair. Field lookup falls back case-insensitively, then to a requested mapped field. |
order[0][column] / order[0][dir] | DataTables values | No | Fallback ordering. The shared engine subtracts one from the column position for CRM2’s leading action column; exact desc reverses the result. |
searchValue / searchField | String / mapped name or native array | No | Case-insensitive substring search over selected mapped fields; omitted field means all map fields. |
Mapped field filters | Scalar or native array | No | Supply id, name, allowedNext, triggers, lastEdited, or colourHex. Text scalars use case-insensitive substring matching, integers equality, and arrays IN. |
referenceDate / dateFrom / dateTo / offsets | Shared date-filter values | No | Inclusive relative-date filtering is available with referenceDate=lastEdited, based on today in the tenant timezone. |
advanceSearch / groupBy | Native arrays | No | CRM2 advanced conditions and mapped grouping. Unknown field names are ignored. |
Example request
$page = FM_api('CustomerTypes_getDataTable', [
'fields' => ['id', 'name', 'colourHex'],
'start' => '0',
'length' => '25',
'draw' => '1',
]);
Example response
{
"data": [
{"id": "12", "name": "Commercial", "colourHex": "#336699"}
],
"draw": 1,
"recordsTotal": "8",
"recordsFiltered": "8"
}
The shared helper can also return a non-DataTables result shape when called without table paging/draw options. Match the calling mode used by your client.
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"missing or invalid parameter: fields"} | fields is absent. |
{"error":"error in database query"} | A mapped/filter query fails. |
Runtime warning or type error | fields or another shared array option is supplied in a malformed scalar shape. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Field names and response keys are camel-case mapped names. Trigger and allowed-next text is not decoded.
- Table mode returns paged data, integer
draw, and scalar database counts. Non-table mode omits table metadata and is unlimited unlesslimitis positive. - The customer-types table has no deleted column, so no active/deleted filter is applied. The tenant timezone matters only to relative date filtering.
- Search, mapped filters, ordering, grouping, advanced filters, and pagination are implemented by the common table helper rather than endpoint-specific code.
See it in Fieldmotion
CRM1
CRM1 uses the older CustomerTypes_getDT positional-row table.
CRM2
Open Settings → Customer Types. The shared display widget derives this endpoint for the list query.
Related endpoints
CustomerTypes_getDTis the legacy CRM1 table route.CustomerType_getRequestedDetailsreads selected known IDs.