Vehicles
Update mapped vehicle data
/a/Vehicle_updateData
Update selected mapped vehicle fields by numeric ID and record field-level history.
When to use this endpoint
Use Vehicle_updateData for CRM2 edit layouts, custom vehicle fields, and integrations that need partial mapped updates. It is safer than the all-fields CRM1 Vehicle_update contract.
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 |
|---|---|---|---|
id | Integer-compatible or native array | Yes | Numeric vehicle ID. The shared updater accepts a native array for bulk changes, but discards individual warnings and errors, so use a scalar ID when the outcome must be checked. |
uuID | String | No | Vehicle UUID. Creation generates a random 32-character hexadecimal value when omitted. The unusual capitalisation is the exact mapped field name. |
name | String | No | Registration value used by CRM2 layouts. It maps to the same database column as reg; creation requires a nonempty name even when reg is also supplied. |
reg | String | No | Legacy alias for the registration column. If both name and reg are supplied, the later reg mapping wins. Duplicate and blank values are not rejected on update. |
description | String | No | Free-text vehicle description. |
costPerDistance | Numeric-compatible | No | Internal cost per mile or kilometre, converted with floatval(). The layout declares a minimum of zero, but the shared server-side converter does not enforce that layout minimum. |
pricePerDistance | Numeric-compatible | No | Customer charge per mile or kilometre, converted with floatval(). Negative values are accepted despite the layout’s zero-minimum metadata. |
location | String | No | Legacy free-text location stored directly on the vehicle. |
lastEdited | Datetime string | No | Mapped edit time. Ordinary mapped writes set last_edited to the current server datetime when a change is made. |
editedUUID | String | No | Legacy edit-source marker. Mapped updates do not populate it automatically. |
meta | JSON-compatible value | No | Complete vehicle metadata value. Arrays are JSON-encoded for storage; a blank string stores SQL NULL. |
cDate | Unix timestamp or date string | No | Creation time stored as a Unix timestamp. Creation defaults to the current server time; mapped reads format it as a datetime. |
customValues | Object or associative array | No | Custom vehicle values stored below meta.custom_values. Supplying this field replaces that nested object. |
Example request
$result = FM_api('Vehicle_updateData', [
'id' => '30124',
'description' => 'Primary service van',
'customValues' => [
'cost-centre' => 'Service',
],
]);
Example response
{"ok":1}
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: id"} | id is absent. |
{"error":"missing or invalid parameter: name"} | A supplied required registration mapping is empty. The same required check is not applied when the field is omitted. |
{"warning":"no updated fields."} | The request contains no recognised mapped field after removing id. |
{"warning":"No data."} | No vehicle matches the scalar numeric ID. |
{"warning":"No Change."} | All supplied mapped values compare equal to the stored values. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- UUIDs are not accepted as identifiers here:
idis integer-converted, so a UUID becomes0. - Only supplied recognised fields are changed. Unknown request fields are ignored and can lead to the no-updated-fields warning.
- A native ID array applies the same change to each numeric ID but always returns
{"ok":1}after the loop, discarding individual errors and warnings. nameandregshare the registration column. Supplying both makesregthe final mapped value.
Side effects
- Changed rows receive the current
last_editeddatetime, invalidate the vehicle cache, and generate Core history for each changed mapped or custom field. edited_uuidis not automatically changed by this route.
See it in Fieldmotion
CRM1
No direct CRM1 caller was found; CRM1 uses Vehicle_update and individual setter routes.
CRM2
Open Stock → Vehicles in CRM2 and filter browser developer tools for the exact function name. Edit a vehicle or save its Vehicle Main form; the shared display/layout widgets derive Vehicle_updateData from the vehicle mapping.
Related endpoints
Vehicle_getRequestedDetailsreads the same mapped and custom fields.Vehicle_updateFieldapplies one mapped field across one or more IDs.