When to use this endpoint

Use for a narrow edit instead of replacing a full layout payload. Choose a mapped field; this route does not translate bundle widget rows.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session. These handlers perform no additional stock, finance, page-role, department or owner check; UI button permissions are not server authorization.

Data is scoped to the authenticated tenant. Session CSRF, signed-request checks and account routing still apply. No stockTracking feature gate is enforced in these handlers.

Requires tenant upgrade 796: stock bundle, storage and inventory tables must have deleted/ddate columns before deploying these handlers.

Parameters

ParameterTypeRequiredDescription
fieldStringYesAllowed mapped names: id, name, stocks, meta, cdate, lastEdited. UI readonly does not prevent writes; avoid field=id because it can rewrite a primary ID.
valScalar or JSON/native structure as mappedYesConverted to the selected map type. Missing/null val is rejected. Blank stocks/meta becomes SQL NULL; other text values remain strings. No required-name validation on this narrow setter.
idScalar or native arrayOne of id/idsInteger-converted target IDs. Takes precedence over ids.
idsScalar or native arrayOne of id/idsAlias when id is absent. Empty arrays are not explicitly rejected; SQL can fail and be treated as no-change.

Example request

$saved = FM_api('StockBundle_updateField', ['id'=>'1042','field'=>'name','val'=>'Service kit']);

Example response

{"ok":1,"oldData":[{"id":"1042","name":"Old name"}]}

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: field"}field omitted.
{"error":"missing or invalid parameter: val"}val omitted/null.
{"error":"missing or invalid field"}Unknown field.
{"error":"missing or invalid parameter: id/ids"}Neither target key supplied.
{"ok":"1","warning":"no change required"}No differing rows, missing targets or failed row read.

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 changed response includes raw prior id/column values in oldData. No-change uses string ok='1' and a warning, whereas a changed save uses numeric ok=1.
  • Required/readonly map metadata is not enforced here; name can be blank and id can be reassigned. Strict comparison before conversion can touch/log a logically unchanged numeric value.
  • Write success is not checked. The operation is not atomic with Core_log history, and there is no compare-and-swap/version guard.
  • The mobile intermediary m/www/php/functions/syncDownloads.php reads stock_bundles as stockBundles. Current app code expands those locally synchronized components; it does not directly call this office endpoint.

Side effects

  • Writes the selected mapped column, server last_edited, invalidates stock_bundles cache and records one Core_log entry. No stock movement or configured event is performed.

See it in Fieldmotion

CRM1

No direct CRM1 caller was found for this exact endpoint; the legacy Stock page uses its separate catalog/container APIs.

CRM2

The generic mapped autosave helpers can build StockBundle_updateField; no dedicated Stock Bundles page action was found for this narrow route. Those pages use updateData for their normal saves.

Related endpoints