Stock inventory, storage and bundles
Load a bundle into its editable stock-table widget
/a/StockBundle_getLayoutDetails
Load a bundle into its editable stock-table widget.
When to use this endpoint
Use when you already know an ID, or need an unpaged source list. Request explicit fields to keep the response small; this is not the paged DataTable endpoint.
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 | No | Integer-converted IDs; takes precedence over ids. Omitted means no ID restriction. A native empty array also removes the ID restriction, not an empty result. JSON-encoded ID lists are not decoded. |
ids | Integer-compatible scalar or native array | No | Alias used only when id is absent; same conversion and empty-list behavior. |
fields | Native array of field-name strings | Yes | Required native field-name array; mapped names are id, name, stocks, meta, cdate, lastEdited, plus widgetTableStockBundle. Unknown/non-string names are ignored and id is always included. JSON text is not decoded. |
Mapped field filters | Scalars or native arrays | No | The mapped names above may also restrict results. Text scalar filters are trimmed, lower-case exact matches (not contains); arrays use IN. Numeric filters integer-convert, including float fields. Filters combine with AND. |
order | Field name, list, or objects {id,dir} | No | Mapped names only; dir=desc reverses that field. No default order is declared. No pagination/limit/start controls are consumed. |
advanceSearch | Native array | No | Native structured conditions on mapped columns: column/id, condition and scalar/native-array value, with optional AND/OR connector and bracket marker. Raw where clauses are rejected. Supported conditions: equal, notEqual, contains, greaterThan, greaterThanOrEqual, lesserThan, lesserThanOrEqual. |
Example request
$rows = FM_api('StockBundle_getLayoutDetails', ['id'=>['1042'], 'fields'=>['name','widgetTableStockBundle']]);
Example response
[{"name":"Service kit","widgetTableStockBundle":[{"stockID":"2042","qty":"2"}],"id":"1042"}]
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: fields"} | fields is omitted. |
{"error":"unsupported raw advanced search"} | advanceSearch contains a raw where key. |
{"error":"missing or invalid parameter: orderDesc"} | Explicit order direction is not asc/desc. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Returns an array, even for one ID; missing IDs are omitted. Unknown fields are ignored, id is included, and no default ordering/result limit is imposed. Empty IDs do not safely mean no rows.
- Database numeric values remain strings/null. datetimeUnix fields are selected with FROM_UNIXTIME and returned as database-formatted date/time strings, not Unix numbers.
- Mapped reads exclude soft-deleted main rows. No additional catalog deleted/archive check is added. Query failure and a genuinely empty selection can both become [].
- stocks/meta are returned as stored JSON text, not decoded component objects. Reading does not expand a bundle into inventory allocations.
- Requesting widgetTableStockBundle adds stocks internally, converts stockID/qty keys and strips internally added stocks unless explicitly requested. Empty stocks yields an empty widget array; components are not hydrated with current catalog names or availability.
- 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
- Read-only; no movement, warehouse quantity update, history, configured event or notification.
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_getLayoutDetails. 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.