Assets
Export asset location history
/a/Assets_exportLocationHistory
Download movement history for selected non-deleted Assets as a CSV with historical whereabouts, owner, dates, duration, and job ID.
When to use this endpoint
Use Assets_exportLocationHistory for the Assets location-history download. It returns CSV and exits rather than returning JSON.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session.
The user must have view permission on pageAssets and exportTableData permission on pageMain. Tenant scoping comes from the authenticated session.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
asset_id | Integer-compatible | No | Restricts the source Asset selection to one ID. |
search | String | No | Case-insensitive substring search across book ID, code, type name, and Asset name before movements are loaded. |
Example request
// Submit as a browser/form request because the response is CSV.
FM_api('Assets_exportLocationHistory', [
'asset_id' => '4821',
]);
Example response
Asset ID,MID,Name,Location,Owner,Dates,Duration,Job ID
4821,9301,Compressor 4,Plant Room,Northwind Service Centre,2026-09-01 - 2026-09-20,19 days,7712
The filename is assets_location_history.csv. Rows are ordered by Asset ID and newest movement ID first.
Whereabouts type 0 resolves an Area, 1 a Customer, and 2 another Asset. Other stored types are not named by this exporter.
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. |
Permission error | Either required permission is missing. |
Empty CSV body or server error | The temporary file or a historical lookup fails; errors are not normalized to the usual JSON envelope. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Soft-deleted source assets are excluded. All movement rows belonging to the selected IDs are exported; there is no movement-date filter or pagination.
- Location and owner are resolved at each movement’s start time. The date range is formatted as local
Y-m-d; duration is whole days, and an open movement reports zero days. - The endpoint only creates and streams a temporary file; it does not change movement history.
See it in Fieldmotion
CRM1
On Assets, export location history with the active Asset/search filters.
CRM2
Choose the Asset location-history export. The current CRM2 caller submits no filters, so it downloads movement history for every non-deleted Asset.
Related endpoints
Assets_getLocationsreturns current/historical location data as JSON.