Assets
Set an asset custom QR value
/a/Asset_setCustomQr
Replace the custom QR-code text stored directly on one asset.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Server-side asset ID after integer conversion. A missing row produces a not-found error; the query includes soft-deleted assets. |
val | String | Yes | Replacement 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
| 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":"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_qrandlast_edited, setsedited_uuidtoAsset_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_getreturnscustom_qrwhen requested.Asset_setUrlstores the separate URL value belowmeta.main.url.