Assets
Get the CRM2 asset table
/a/Assets_getDataTable
Query named Asset fields through CRM2’s mapped table engine, including customer-scope settings and derived service/job data.
When to use this endpoint
Use Assets_getDataTable for CRM2-style Asset tables, selectors, or export selection. Use Assets_list for a smaller integration-oriented list.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler requires login or an established tenant database context and performs no additional Asset-page or role-permission check unless the page says otherwise.
Every query and write uses the authenticated tenant’s tables. CRM1 and CRM2 may hide actions through client-side permissions that these collection routes do not repeat.
For non-client-admin users, the tenant permissions departmentBasedFilter and accountManagerBasedFilter on pageMain restrict assets through their owner customers. When both settings apply, both restrictions must match; an empty permitted-customer set returns no rows.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fields | Native array | No | Native array of mapped Asset fields. The endpoint appends id even when this parameter is omitted; unknown names are ignored. |
isTable | Integer-compatible | No | Defaults to DataTables mode. Exact integer 0 returns an unwrapped data array and permits the optional limit. |
draw / start / length | Integer-compatible | No | DataTables counter, zero-based offset, and page size. Defaults are 0, 0, and 10. |
limit | Integer-compatible | No | Positive maximum used only outside table mode; zero leaves the result unbounded. |
orderBy / orderDesc or order[0] | Mapped field / DataTables ordering | No | Sort controls accepted by the shared mapped-table helper. Unknown mapped names fall back to a selected field. |
searchValue / searchField | String / mapped field or array | No | Case-insensitive substring search over selected mapped fields. searchField defaults to All. |
referenceDate / dateFrom / dateTo | Mapped date field / integer day offsets | No | Relative-date filtering in the tenant timezone. The offsets are relative to today, not date strings. |
advanceSearch | Native array | No | Shared advanced-filter clauses. Raw where expressions are an internal trusted-client mechanism, not a safe public integration feature. |
owner / location | Object or array of objects | No | CRM2 selector values containing id. Owner ID -1 means unowned; location ID -1 means whereabouts not set. Supplying locationId with owner values changes the owner filter to “owned by or located at” those customer IDs. |
childJobAndAsset | Boolean-compatible | No | With customer owner IDs, also includes their direct child customers when the list contains 0. |
warrantyInOut | Array | No | OR-combined warranty states: 1 is after today and 2 is today or earlier. |
contracts | Array of IDs | No | Selects assets linked through the contracts metadata cache. See the legacy warning below. |
nextDateStatus | String | No | due selects next-service dates through today; dueSoon uses each asset’s amber service-frequency threshold. |
owned | String | No | Exact true selects assets whose owner customer has the tenant metadata flag owned=1. |
hasFiles | Array | No | A single 0 requires at least one file; a single 1 requires none. Selecting both applies no file filter. |
Example request
$table = FM_api('Assets_getDataTable', [
'fields' => ['id', 'name', 'code', 'owner', 'locationName', 'nextDate'],
'draw' => '4',
'start' => '0',
'length' => '25',
'searchField' => 'All',
'searchValue' => 'compressor',
]);
Example response
{
"data": [
{
"id": "4821",
"name": "Compressor 4",
"code": "CMP-004",
"owner": {"id": "1042", "value": "Northwind Service Centre"},
"locationName": "Plant Room",
"nextDate": [{"id": "7712", "aid": "4821", "jobTime": "2027-01-01 09:00:00", "userID": "37", "jobRef": "JOB-7712"}]
}
],
"draw": 4,
"recordsTotal": "240",
"recordsFiltered": "1"
}
Available mapped fields are id, name, code, active, value, meta, lastEdited, cdate, typeID, locationID, locationType, location, locationName, ownerID, owner, appID, departments, archived, editedUuid, warranty, bookID, customQR, make, model, files, contacts, jobDetails, locID, and mapped metadata/custom fields. Additional mapped fields include metaServiceFrequency, metaLastVisited, metaLastServiced, metaNextDate, metaNextServiced, metaIsFlagged, metaCreditTerms, customValues, customMainValues, metaSkills, and contracts.
lastVisited returns {id, jobTime} with an epoch value. nextDate returns incomplete direct jobs with SQL date-time strings. allocatedToJob returns future/today incomplete jobs whose metadata names the asset.
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":"error in database query"} | A mapped, advanced, or special filter produces a failing query. |
Empty or unexpectedly broad data | Unknown mapped fields and unsupported filter values are generally ignored rather than rejected. |
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 assets are excluded. Table mode returns
data,draw,recordsTotal, andrecordsFiltered; non-table mode returns onlydataand is unbounded unlesslimitis positive. referenceDate=dateNextorlastVisitedselects assets through qualifying non-deleted jobs in the relative date window.lastMaintenancejoins recurrence history and can duplicate an asset when several maintenance rows match.- Owner- and account-manager-based restrictions use owner customers, not current whereabouts. Client administrators bypass both tenant settings.
- Derived maintenance, last-visit, next-job, and allocation fields perform extra per-row queries and can be expensive on large pages. The allocation lookup does not exclude soft-deleted jobs.
See it in Fieldmotion
CRM1
No production CRM1 caller was found; CRM1 uses Assets_getDT.
CRM2
Open Assets, use Asset selectors, or run service-maintenance views. CRM2 supplies layout fields, filters, sorting, and pagination to this endpoint and uses non-table mode while collecting export IDs.
Related endpoints
Assets_getDTserves the positional CRM1 table.Assets_getAssetTableExportDatareturns CRM2 export rows.