Job types
Query job types through the field map
/a/JobTypes_getDataTable
Query job types through CRM2’s named field map with shared filtering, searching, ordering, grouping, and paging controls.
When to use this endpoint
Use JobTypes_getDataTable for CRM2-style configurable tables or a named-field query. Use JobTypes_getDT only when the legacy positional table contract is required.
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 | Requested mapped keys: id, name, priority, lastEdited, notes, meta, archived, nominalCode, taxSettings, department, metaFormID, metaSendNotification, metaNotificationEmail, and metaOrderNum. Unknown keys are ignored and id is always returned. |
isTable | Integer string | No | Defaults to table mode. Exact integer 0 returns only data and enables the optional limit. |
draw / start / length | Integer strings | No | Table counter, offset, and page size; defaults are 0, 0, and 10. No endpoint-specific maximum is imposed. |
limit | Integer string | No | Positive maximum in non-table mode. Zero or a negative value means unlimited. |
orderBy / orderDesc | Mapped name / direction | No | Explicit ordering. Field lookup falls back case-insensitively and then to a requested mapped key. orderDesc is inserted without normalization. |
order[0][column] / order[0][dir] | DataTables values | No | Fallback table order. The shared helper subtracts one from the column index for CRM2’s action column; exact desc reverses the result. |
searchValue / searchField | String / mapped name or native array | No | Case-insensitive substring search over selected map fields. Omitted searchField searches all mapped fields. |
Mapped field filters | Scalar or native array | No | Supply any mapped key. Text scalars use case-insensitive substrings, numeric scalars equality, and arrays IN. Metadata subfields address their JSON paths. |
referenceDate / dateFrom / dateTo / offsets | Shared date-filter values | No | Inclusive relative dates use today in the tenant timezone. lastEdited is the meaningful date map entry. |
advanceSearch / groupBy | Native arrays | No | CRM2 advanced conditions and mapped grouping. Unknown mapped names are ignored. |
Example request
$page = FM_api('JobTypes_getDataTable', [
'fields' => ['id', 'name', 'priority', 'archived'],
'archived' => '0',
'start' => '0',
'length' => '25',
'draw' => '4',
]);
Example response
{
"data": [
{"id": "42", "name": "Emergency repair", "priority": "4", "archived": "0"}
],
"draw": 4,
"recordsTotal": "8",
"recordsFiltered": "6"
}
Non-table mode returns only {"data":[...]}. Stored meta remains text; named metadata keys are extracted into their requested response keys.
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"} | The generated mapped/filter query fails. |
Runtime warning or type error | fields, grouping, or advanced-search values use unsupported scalar shapes. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Archived and active rows are both eligible unless the caller supplies an
archivedfilter. Job types have no soft-delete filter. - Table mode applies paging and returns database scalar counts. Non-table mode is unlimited unless
limitis positive. - Relative date boundaries use the tenant timezone; all other filters are tenant-scoped but independent of tenant settings.
See it in Fieldmotion
CRM1
CRM1 uses JobTypes_getDT for the Job Types table and does not directly call this mapped route.
CRM2
Open Settings → Job Types. The shared display widget derives JobTypes_getDataTable from the plural API prefix and sends the visible/configured mapped fields.
Related endpoints
JobType_getRequestedDetailsuses the same field map without table counts or pagination.JobType_updateDatachanges the same mapped fields.