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

ParameterTypeRequiredDescription
fieldsNative arrayYesMapped 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.
isTableInteger-compatibleNoDefaults to table mode. Exact integer value 0 returns only data and allows the optional non-table limit.
draw, start, lengthInteger-compatibleNoTable counter, offset, and page size; defaults are 0, 0, and 10.
limitInteger-compatibleNoPositive limit used only outside table mode. Zero means unbounded.
orderBy / orderDescMapped field / directionNoExplicit mapped ordering. Unknown field names fall back to the first requested mapped field.
order[0][column] / order[0][dir]Integer / stringNoDataTables ordering fallback; the column index is reduced by one before resolving the requested field list.
searchValue / searchFieldString / mapped field or arrayNoCase-insensitive substring search across selected mapped fields. Special searchField=userID searches one user name and then filters by that first matching user ID.
userIDNative array of objectsNoUser 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, idScalar or native arrayNoMapped filters. Text scalars use case-insensitive substring matching; arrays use exact IN matching.
costPerDistance, pricePerDistance, cDateScalar or native arrayNoNumeric filters. Scalar decimal costs are integer-truncated; array decimal values preserve their fractional conversion.
referenceDate, dateFrom, dateToMapped field and integer day offsetsNoTenant-timezone relative-date filtering. Both offsets are needed to apply a range.
advanceSearch, groupByNative arraysNoShared 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

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 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

  • userID joins may duplicate a vehicle when several selected users reference the same numeric vehicle ID; the wrapper does not add DISTINCT or grouping.
  • The user join recognises numeric assignments only. Legacy users whose vehicle_id stores 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. cDate is formatted as a datetime and customValues is 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