Contract types
Build the CRM2 contract-types table
/a/ContractTypes_getDataTable
Build CRM2’s selectable, filterable Contract Types table with named fields and table counts.
When to use this endpoint
Use ContractTypes_getDataTable for CRM2’s Contracts → Types table. For a small ordered picker, use ContractTypes_list.
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 | Array | Yes | Native array containing id, name, disableInvoicing, lastEdited, and/or meta. Unknown values 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, offset, and page size; defaults are 0, 0, and 10. |
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 / name or array | No | Case-insensitive substring search over selected mapped fields; omitted field means all map fields. |
Mapped field filters | Scalar or array | No | 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 | Arrays | No | CRM2 advanced conditions and mapped grouping. Unknown field names are ignored. |
Example request
$table = FM_api('ContractTypes_getDataTable', [
'fields' => ['id', 'name', 'disableInvoicing', 'lastEdited'],
'draw' => '4',
'start' => '0',
'length' => '25',
'orderBy' => 'name',
'orderDesc' => 'asc',
]);
Example response
{
"data": [
{"id": "31", "name": "Planned service", "disableInvoicing": "0", "lastEdited": "2026-09-25 14:30:00"}
],
"draw": 4,
"recordsTotal": "8",
"recordsFiltered": "8"
}
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. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Table mode returns paged data, integer
draw, and scalar database counts. Non-table mode omits table metadata and is unlimited unlesslimitis positive. - Both counts include all tenant contract types because there is no status/deleted column.
recordsFilteredapplies search, mapped, date, group, and advanced filters. - Raw
metaremains text. There is no role-based row filter in the handler. - Tenant feature bit
64controls visibility of the Contracts UI but is not checked by this handler.
See it in Fieldmotion
CRM1
A production-source search found no CRM1 caller. CRM1’s table uses the older Contracts_getTypesDT route documented with Contracts.
CRM2
Open Contracts → Types and change columns, search, sorting, or paging. The shared display widget derives ContractTypes_getDataTable from its plural API prefix.
Related endpoints
ContractType_getRequestedDetailsprovides unpaged exact-detail queries.Contracts_getTypesDTis CRM1’s positional table.