Stock inventory, storage and bundles
Page and filter storage location rows for CRM2 lists
/a/StockStorages_getDataTable
Page and filter storage location rows for CRM2 lists.
When to use this endpoint
Use for the CRM2 storage picker table or picker. For an unpaged stored-record lookup, use the singular getRequestedDetails 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 |
|---|---|---|---|
fields | Native array of field-name strings | Yes | Mapped projections: id, name, parentID, lastEdited. Unknown names are ignored; id is always added. No JSON-text decoding. |
isTable | Integer-compatible scalar | No | Defaults to table mode. Integer 0 returns only {data:[...]} and disables paging/counts. |
start | Integer-compatible scalar | No | Non-negative integer offset, default 0. |
length | Integer-compatible scalar | No | Positive integer page size, default 10. -1 is rejected; use isTable=0 for an unpaged result. |
draw | Integer-compatible scalar | No | Table-mode draw echo, default 0. |
limit | Integer-compatible scalar | No | Non-negative integer limit in unpaged mode; omitted/0 means no result limit. |
searchValue | String | No | Trimmed lower-case contains search. Blank/falsey trimmed text disables it; LIKE wildcards remain active. |
searchField | String or native array | No | Search names or All (default). Invalid names contribute no search predicate; search is against mapped columns, not automatically related display names. |
Mapped field filters | Scalars or native arrays | No | Text scalar values are case-insensitive contains; arrays use IN. Numeric scalar filters integer-convert. Combines with search and endpoint filters. |
orderBy / orderDesc | Mapped name / direction text | No | Supply both for explicit order. orderBy matches a mapped name case-insensitively, with unknown names falling back to a valid projected field. orderDesc must be asc/desc and is normalized to lower case. |
order | DataTables order array | No | Without explicit order pair, order[0].column is converted then reduced by one; default mapped first field ascending. dir=desc reverses it. |
groupBy | Native field-name array | No | Groups by accepted mapped fields. Counts are not grouped result counts. |
referenceDate | Mapped date/timestamp field name | No | Activates date/hour controls for that field. |
dateFrom / dateTo | Integer-compatible day offsets | No | Both present: inclusive start-day 00:00:00 through end-day 23:59:59 relative to today's tenant date (timezone setting, UTC fallback). These are relative offsets, not YYYY-MM-DD dates. |
offsetFrom / offsetTo | Objects with hour,minute | No | Hour offsets are negated and minute offsets added to their respective date boundaries. |
timeRangeFrom / timeRangeTo | Integer-compatible hours | No | Hour filter starts only when timeRangeFrom is present; a lone timeRangeTo is ignored. Default ending hour 23, reversed bounds swap. Uses tenant timezone with Europe/London fallback. |
advanceSearch | Native condition 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
$page = FM_api('StockStorages_getDataTable', ['fields'=>['id','name'], 'start'=>'0', 'length'=>'10', 'draw'=>'1']);
Example response
{"data":[{"id":"1042","name":"Parts cabinet"}],"draw":1,"recordsTotal":"1","recordsFiltered":"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: fields"} | fields omitted. |
{"error":"error in database query"} | The main list query fails, including invalid SQL from unsafe legacy controls. |
{"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
- Table mode returns data, integer draw, recordsTotal and recordsFiltered. Counts are database scalars, often strings; total counts active rows in the tenant table and filtered counts match SQL predicates before grouping.
- isTable=0 returns only data and has no default limit. It orders by referenceDate ascending when that mapped field is supplied; otherwise no default order is imposed. Table mode defaults to first valid projected field ascending. Unknown fields are skipped; id is always included.
- An active-only deleted=0 filter is applied to the main table. Unix timestamp fields render through database FROM_UNIXTIME.
- No exact caller was found in current app JavaScript or m/www for this office endpoint; app stock quantities use the separate mobile sync/transaction paths.
Side effects
- Read-only: no default storage creation, stock movement, history, edit timestamp or 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
The Stock Locations tree calls StockStorage_getRequestedDetails, not this DataTable route. Generic mapped table helpers can build StockStorages_getDataTable for the stockStorage namespace; no dedicated direct call was found in the tree page.
Related endpoints
StockStorage_getRequestedDetailsreads stored mapped values; an omitted ID can retrieve all active tenant rows.StockStorage_createDatacreates a new storage location rather than changing physical warehouse stock.