When to use this endpoint

Use for the CRM2 Stock Inventory 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

ParameterTypeRequiredDescription
fieldsNative array of field-name stringsYesMapped projections: id, name, stockID, supplierID, supplier, storageID, storage, goodReceivedID, qty, cost, price, reference, receivedDate, lastEdited, cdate. Unknown names are ignored; id is always added. No JSON-text decoding.
isTableInteger-compatible scalarNoDefaults to table mode. Integer 0 returns only {data:[...]} and disables paging/counts.
startInteger-compatible scalarNoNon-negative integer offset, default 0.
lengthInteger-compatible scalarNoPositive integer page size, default 10. -1 is rejected; use isTable=0 for an unpaged result.
drawInteger-compatible scalarNoTable-mode draw echo, default 0.
limitInteger-compatible scalarNoNon-negative integer limit in unpaged mode; omitted/0 means no result limit.
searchValueStringNoTrimmed lower-case contains search. Blank/falsey trimmed text disables it; LIKE wildcards remain active.
searchFieldString or native arrayNoSearch names or All (default). Invalid names contribute no search predicate; search is against mapped columns, not automatically related display names.
Mapped field filtersScalars or native arraysNoText scalar values are case-insensitive contains; arrays use IN. Numeric scalar filters integer-convert. Combines with search and endpoint filters.
orderBy / orderDescMapped name / direction textNoSupply 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.
orderDataTables order arrayNoWithout explicit order pair, order[0].column is converted then reduced by one; default mapped first field ascending. dir=desc reverses it.
groupByNative field-name arrayNoNative mapped field-name array for ordinary lists. A non-empty groupBy is rejected with container availability.
referenceDateMapped date/timestamp field nameNoActivates date/hour controls for that field.
dateFrom / dateToInteger-compatible day offsetsNoBoth 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 / offsetToObjects with hour,minuteNoHour offsets are negated and minute offsets added to their respective date boundaries.
timeRangeFrom / timeRangeToInteger-compatible hoursNoHour 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.
advanceSearchNative condition arrayNoNative 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.
isAllBoolean-compatible scalarNoOmitted/PHP-falsey restricts stored main.qty>0. Truthy removes that predicate.
supplierParamsNative arrayNoNative array of positive integer supplier IDs. Uses exact supplier_id IN membership, not regex substring matching; [] selects no rows.
statusParamsNative arrayNoNative array containing only 0 (active) and/or 1 (archived). Non-empty input joins the catalog and filters is_archived; [] adds no archive restriction. This does not exclude deleted catalog references.
containerObject {id,type}NoObject with id and a supported EnumStockSource type. Owner IDs are bounded scalar text, preserving UUIDs. type=0 subtracts positive non-dispatched allocations; other types return that owner/type's allocation quantities. Adds stockID and qty to output.

Example request

$page = FM_api('StockInventories_getDataTable', ['fields'=>['id','name'], 'start'=>'0', 'length'=>'10', 'draw'=>'1']);

Example response

{"data":[{"id":"1042","name":"Filter cartridge"}],"draw":1,"recordsTotal":"1","recordsFiltered":"1"}

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: 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.
{"error":"groupBy is not supported with container"}Availability request also asks for grouping.
{"error":"invalid saved inventory allocations"}Saved structured allocations contain malformed entries.
{"error":"inventory read failed"}Allocation lookup fails.

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. Total counts active rows in the tenant table. Without container, filtered counts reflect SQL predicates; with container, recordsFiltered is an integer count after availability exclusion, before final pagination.
  • 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.
  • supplier/storage requested fields join their tables and add nested {id,name} objects, unlike the singular detail endpoint. Temporary flattened aliases can remain alongside these objects. Joined suppliers and storage rows exclude soft-deleted rows.
  • 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.
  • container forces stockID and qty into output, preserving fractional quantities. Structured meta.inventory allocations take precedence over the legacy inventory_id/amt representation; duplicate structured entries are summed once each. Non-empty container owner IDs are not integer-converted, so UUID owners remain addressable.
  • Availability is computed while scanning stable 500-row SQL batches. Non-positive adjusted rows are excluded before the final offset/length or unpaged limit; recordsFiltered counts available matching rows, while recordsTotal still counts all active inventory rows.
  • This availability scan must inspect all SQL-matching rows to compute an accurate count. It keeps only the requested page (unless unpaged without a limit) but may take longer on a large inventory. Ordering remains based on stored mapped fields, with inventory ID as a stable tie-breaker.
  • Invalid structured allocation quantities/types return an error rather than being silently ignored. Query and allocation read failures are reported.
  • recordsTotal counts only active main inventory rows; isAll includes active zero/negative balances, never deleted rows. Supplier/storage joins also exclude deleted linked rows.

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

Open Stock Inventory or a Stock Location's inventory table. The table uses StockInventories_getDataTable through the StockInventory/StockInventories prefixes; mapped detail helpers read StockInventory_getRequestedDetails. Filter Network for StockInventories_getDataTable.

Related endpoints