Stock inventory, storage and bundles
Replace supplied mapped bundle values
/a/StockBundle_updateData
Replace supplied mapped bundle values.
When to use this endpoint
Use for partial mapped changes. Omitted mapped fields retain their current values; JSON values replace the complete property, not individual keys.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible scalar or native array | Yes | Update target; scalar integer-converts. Native arrays execute sequential updates, not one transaction; per-row errors/warnings are discarded and the bulk call returns ok. |
name | String | No | Supplied non-empty name replaces the current value; omission leaves it unchanged. Blank is rejected, but whitespace is not trimmed. No uniqueness check. |
stocks | JSON text or native array | No | Stored component list, normally [{stockID:1042,qty:2}]. Replaces the entire saved list; no stock existence, quantity or schema validation is performed. |
meta | JSON text or object | No | Replaces the entire metadata value. No merge with existing keys. |
widgetTableStockBundle | JSON text or native array | No | Widget rows use stockID and qty. Converted rows override stocks when supplied; unrecognized row keys, including id, are dropped. A present noConvert key bypasses conversion and is removed; this is a legacy internal control, not an integration format. |
cdate | Unix seconds or date/time string | No | Creation timestamp defaults to now; writable despite UI readonly metadata. |
lastEdited | Unix seconds or date/time string | No | Creation accepts a supplied value; omitted defaults to now. Changed updates set last_edited to server Unix seconds. |
Example request
$saved = FM_api('StockBundle_updateData', ['id'=>'1042', 'name'=>'Service kit']);
Example response
{"ok":1}
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 omitted. |
{"error":"missing or invalid parameter: name"} | Supplied name is blank. |
{"warning":"No data."} | No target row found, or the mapped-column read fails. |
{"warning":"No Change."} | All supplied mapped values already match. |
{"warning":"no updated fields."} | No supplied field is mapped. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- UI readonly/hidden field metadata is not a write-access guard. Values integer-/float-convert according to the map; no minimum, finite-value or foreign-object validation is supplied here.
- Updates are not atomic with history and do not check the write result before returning ok. Re-read saved values before replaying an uncertain response.
- widgetTableStockBundle, when supplied, takes precedence over stocks. Its supported keys are stockID and qty; id is not an alias for stockID. The saved component list is replaced as a whole.
- 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 stock_bundles and invalidates its cache. Changed updates record before/after history and set last_edited to server Unix seconds.
- Does not update warehouse in_stock, allocate stock, create movement history, send emails, call an external service or fire a configured event.
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
Open Stock Bundles. Its mapped table uses StockBundles_getDataTable; Create/Edit uses layoutStockBundleCreate/layoutStockBundleUpdate and the Layout stockBundle mapping. Filter Network for StockBundle_updateData. Bulk Delete posts one ID per request; direct updateField has no dedicated call in this page.
Related endpoints
StockBundle_getRequestedDetailsreads stored mapped values; an omitted ID can retrieve all active tenant rows.StockBundle_createDatacreates a new bundle rather than changing physical warehouse stock.