When to use this endpoint

Use Asset_setLocationType only for the CRM1 customer Assets table, where the type and target ID are saved separately.

Changing type without changing the existing target can temporarily or permanently reinterpret that numeric ID as a different object.

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

ParameterTypeRequiredDescription
idInteger stringYesPositive asset ID. Archived and soft-deleted rows are included.
valInteger stringNoNew type after integer conversion: 0 site, 1 customer, or 2 asset. Omission converts to valid type zero. Values outside 0–2 are rejected.

Example request

$result = FM_api('Asset_setLocationType', [
	'id' => '4821',
	'val' => '1',
]);

Example response

{
  "ok": 1
}

An unchanged type returns {"ok":1,"msg":"no changes needed"}. The movement ID created by a real change is not returned.

Errors and unusual responses

ResponseCondition
{"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":"missing or invalid parameter: val"}The integer-converted type is below 0 or above 2.
{"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

  • A change backfills initial history if needed, archives the resolved old/new addresses, and appends a movement with the unchanged location ID and no owner change.
  • No-change comparison returns before updates or audit effects.
  • This is a single-record mutation with no filtering or pagination.

Side effects

  • Updates location_type, last_edited, and edited_uuid="Asset_setLocationType"; invalidates asset and customer-asset caches; writes address/movement history; and records an asset audit entry.

See it in Fieldmotion

CRM1

Change the Location Type control in a customer’s Assets table and filter Network requests for Asset_setLocationType.

CRM2

No direct production CRM2 caller was found.

Related endpoints