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

ParameterTypeRequiredDescription
fieldsArrayYesNative array containing id, name, disableInvoicing, lastEdited, and/or meta. Unknown values are ignored and id is always returned.
isTableInteger stringNoDefaults to table mode. Exact integer 0 returns only data and permits optional limit.
draw / start / lengthInteger stringsNoTable counter, offset, and page size; defaults are 0, 0, and 10.
limitInteger stringNoPositive non-table maximum; zero means unlimited.
orderBy / orderDescMapped name / directionNoExplicit sort pair. Field lookup falls back case-insensitively, then to a requested mapped field.
order[0][column] / order[0][dir]DataTables valuesNoFallback ordering. The shared engine subtracts one from the column position for CRM2’s leading action column; exact desc reverses the result.
searchValue / searchFieldString / name or arrayNoCase-insensitive substring search over selected mapped fields; omitted field means all map fields.
Mapped field filtersScalar or arrayNoText scalars use case-insensitive substring matching, integers equality, and arrays IN.
referenceDate / dateFrom / dateTo / offsetsShared date-filter valuesNoInclusive relative-date filtering is available with referenceDate=lastEdited, based on today in the tenant timezone.
advanceSearch / groupByArraysNoCRM2 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

ResponseCondition
{"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 unless limit is positive.
  • Both counts include all tenant contract types because there is no status/deleted column. recordsFiltered applies search, mapped, date, group, and advanced filters.
  • Raw meta remains text. There is no role-based row filter in the handler.
  • Tenant feature bit 64 controls 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