When to use this endpoint

Use Asset_setCustomQr when an asset needs a caller-defined QR value rather than a generated link.

The value is opaque text; this handler does not generate, parse, or validate a QR image or URL.

Authentication and permissions

The handler requires an authenticated tenant context, established by signed API-key fields or a CRM session. It checks the tenant table prefix but does not separately require a logged-in user ID.

No page, role, or asset permission is checked.

Parameters

ParameterTypeRequiredDescription
idInteger stringYesServer-side asset ID after integer conversion. A missing row produces a not-found error; the query includes soft-deleted assets.
valStringYesReplacement QR text. Blank is accepted. The endpoint does not enforce the schema’s maximum length before writing.

Example request

$result = FM_api('Asset_setCustomQr', [
	'id' => '4821',
	'val' => 'FM-ASSET-CMP-004',
]);

Example response

{
  "ok": 1
}

A loosely equal stored value returns {"ok":1,"warning":"no change required"}.

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":"no ID provided"}id is omitted.
{"error":"no val provided"}val is omitted.
{"error":"asset does not exist"}No asset row has the converted 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

  • The no-change path returns before timestamps or audit data change.
  • The existence query and update do not exclude archived or soft-deleted assets.
  • This is a single-record mutation; it provides no list filtering or pagination.

Side effects

  • A real change attempts to update custom_qr and last_edited, sets edited_uuid to Asset_setCustomQr, invalidates the asset cache, and writes an asset audit entry.

See it in Fieldmotion

CRM1

Open an asset edit page or the asset editor in a customer’s Assets tab, change Custom QR, and filter Network requests for Asset_setCustomQr.

CRM2

No direct production CRM2 call to Asset_setCustomQr was found; CRM2 manages asset QR data through its newer update UI.

Related endpoints

  • Asset_get returns custom_qr when requested.
  • Asset_setUrl stores the separate URL value below meta.main.url.