Vehicles
Query the CRM2 Vehicles table
/a/Vehicles_getDataTable
Query mapped vehicle rows for CRM2 with field selection, filters, user assignment search, sorting, and pagination.
When to use this endpoint
Use Vehicles_getDataTable for CRM2’s Vehicles screen or another mapped table that needs camelCase vehicle fields and server-side paging.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler requires login but performs no additional Vehicles-page, create, edit, delete, or role-permission check.
All reads and writes use the authenticated tenant’s tables. CRM1 and CRM2 may hide controls through client-side permissions; these routes do not repeat those UI checks.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fields | Native array | Yes | Mapped fields from id, uuID, name, reg, description, costPerDistance, location, lastEdited, editedUUID, pricePerDistance, meta, cDate, and customValues. Unknown names are skipped and id is always added. |
isTable | Integer-compatible | No | Defaults to table mode. Exact integer value 0 returns only data and allows the optional non-table limit. |
draw, start, length | Integer-compatible | No | Table counter, offset, and page size; defaults are 0, 0, and 10. |
limit | Integer-compatible | No | Positive limit used only outside table mode. Zero means unbounded. |
orderBy / orderDesc | Mapped field / direction | No | Explicit mapped ordering. Unknown field names fall back to the first requested mapped field. |
order[0][column] / order[0][dir] | Integer / string | No | DataTables ordering fallback; the column index is reduced by one before resolving the requested field list. |
searchValue / searchField | String / mapped field or array | No | Case-insensitive substring search across selected mapped fields. Special searchField=userID searches one user name and then filters by that first matching user ID. |
userID | Native array of objects | No | User assignment filter such as [['id' => 94012]]. JSON strings and scalar IDs are ignored. Vehicles are joined through users.vehicle_id = vehicles.id. |
name, reg, uuID, description, location, lastEdited, editedUUID, meta, customValues, id | Scalar or native array | No | Mapped filters. Text scalars use case-insensitive substring matching; arrays use exact IN matching. |
costPerDistance, pricePerDistance, cDate | Scalar or native array | No | Numeric filters. Scalar decimal costs are integer-truncated; array decimal values preserve their fractional conversion. |
referenceDate, dateFrom, dateTo | Mapped field and integer day offsets | No | Tenant-timezone relative-date filtering. Both offsets are needed to apply a range. |
advanceSearch, groupBy | Native arrays | No | Shared mapped-table advanced conditions and grouping controls. |
Example request
$table = FM_api('Vehicles_getDataTable', [
'fields' => ['id', 'reg', 'costPerDistance', 'pricePerDistance', 'description'],
'draw' => '3',
'start' => '0',
'length' => '25',
'orderBy' => 'reg',
'orderDesc' => 'asc',
]);
Example response
{
"data": [{"id":"30124","reg":"241-D-12001","costPerDistance":"0.4200","pricePerDistance":"0.7500","description":"Service van"}],
"draw": 3,
"recordsTotal": "18",
"recordsFiltered": "18"
}
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 generated field, search, grouping, or ordering 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
userIDjoins may duplicate a vehicle when several selected users reference the same numeric vehicle ID; the wrapper does not addDISTINCTor grouping.- The user join recognises numeric assignments only. Legacy users whose
vehicle_idstores a UUID are not matched by this filter. - Table mode returns data, integer draw, and scalar counts; non-table mode returns only data.
- Vehicles have no deleted-state filter.
cDateis formatted as a datetime andcustomValuesis extracted from metadata.
See it in Fieldmotion
CRM1
CRM1 uses Vehicles_getDT.
CRM2
Open Stock → Vehicles in CRM2 and filter browser developer tools for the exact function name. Loading the list, applying vehicle/user filters, sorting, and paging calls this endpoint through the display widget.
Related endpoints
Vehicle_getRequestedDetailsreads mapped details without table paging.Vehicles_getDTis the positional CRM1 alternative.