Assets
Set an asset location ID
/a/Asset_setLocationId
Replace only the target ID of an asset’s legacy whereabouts and append movement history.
When to use this endpoint
Use Asset_setLocationId only for the CRM1 customer Assets table, where type and ID are edited through separate controls.
Prefer Asset_setLocation when the complete legacy pair is known, or Asset_updateData for guarded new integrations.
Authentication and permissions
The handler requires an authenticated tenant context, established by signed API-key fields or a CRM session. It performs no page, role, or asset permission check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Positive asset ID. The lookup includes archived and soft-deleted rows. |
val | Integer string | No | New location target ID. Omitted, blank, or nonnumeric values become 0. The target is not validated against the asset’s current location type. |
Example request
$result = FM_api('Asset_setLocationId', [
'id' => '4821',
'val' => '1042',
]);
Example response
{
"ok": 1
}
An unchanged ID returns {"ok":1,"msg":"no changes needed"}. A real change also returns only ok; its new movement ID is not exposed.
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, zero, or otherwise not positive. |
{"error":"asset does not exist"} | No asset row has that ID. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- No-change comparison is string-loose and returns before timestamps, logs, or movements change.
- A change backfills an initial movement if needed, records old/new resolved address data, closes the active movement, and inserts a new row with the unchanged type and a null owner-change marker.
- This is a single-record mutation with no filtering or pagination.
Side effects
- Updates
location_id,last_edited, andedited_uuid="Asset_setLocationId"; invalidates asset and customer-asset caches; writes address/movement history; and records an asset audit entry.
See it in Fieldmotion
CRM1
Edit the Location ID control in a customer’s Assets table and filter Network requests for Asset_setLocationId.
CRM2
No direct production CRM2 caller was found.
Related endpoints
Asset_setLocationTypechanges the other half of the legacy pair.Asset_getWhereaboutsBlockedTargetssupports the guarded CRM2 picker.