Assets
Set a mapped asset field
/a/Asset_setField
Set one named Asset map field across one or more non-deleted asset rows.
When to use this endpoint
Asset_setField is a legacy alias of Asset_updateField. Use it only for callers already tied to this route name.
For relationship fields, use focused owner/location endpoints or Asset_updateData so history and related caches stay coherent.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.
The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
field | String | Yes | Exact Asset map key, for example name, code, active, warranty, registrationNumber, or metaIsFlagged. Unknown names are rejected. Hidden/read-only layout flags are not enforced. |
val | Mixed | Yes | New value for every matched asset. Null counts as absent. Type conversion follows the map; a date must be blank or a real YYYY-MM-DD. |
id / ids | Integer string or array | Yes | One ID or a list. If id exists it wins; scalar values become a one-item array and all values are integer-converted. |
Example request
$result = FM_api('Asset_setField', [
'ids' => ['4821', '4822'],
'field' => 'active',
'val' => '0',
]);
Example response
{
"ok": 1,
"oldData": [
{"id": "4821", "active": "1"},
{"id": "4822", "active": "1"}
]
}
If no matched row needs a change, the route returns {"ok":"1","warning":"no change required"}; note the string ok in that branch.
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: field"} | field is absent. |
{"error":"missing or invalid parameter: val"} | val is absent or null. |
{"error":"missing or invalid field"} | The field is not present in the Asset map. |
{"error":"missing or invalid parameter: id/ids"} | Neither ID key is present. |
{"error":"invalid date parameter: FIELD"} | A date field receives a nonblank invalid ISO date. |
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; archived assets remain. IDs not found are silently omitted from
oldData. - For normal columns, all changed IDs are updated in one query. Metadata-backed fields are read, changed, and written one row at a time.
- Strict comparison is used for normal-column no-change detection, while nested metadata uses loose comparison.
last_editedis refreshed on changes. - There is no pagination. The response returns raw pre-update rows, including the complete underlying
metavalue for metadata fields.
Side effects
- Invalidates the asset cache and writes one generic asset audit entry covering changed IDs. It does not send notification-service events.
See it in Fieldmotion
CRM1
No direct production CRM1 caller was found.
CRM2
No direct production CRM2 caller was found; configurable layout saves use Asset_updateData.
Related endpoints
Asset_updateFieldhas the same implementation and response contract.Asset_updateDataperforms wrapper-specific owner, whereabouts, history, and notification work.