When to use this endpoint

Use for the CRM2 Stock Bundles 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, stocks, meta, cdate, lastEdited. 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 arrayNoGroups by accepted mapped fields. Counts are not grouped result counts.
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.

Example request

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

Example response

{"data":[{"id":"1042","name":"Service kit"}],"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.

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. Bundle stocks/meta remain encoded JSON text.
  • 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 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 Bundles. Its mapped table uses StockBundles_getDataTable; Create/Edit uses layoutStockBundleCreate/layoutStockBundleUpdate and the Layout stockBundle mapping. Filter Network for StockBundles_getDataTable. Bulk Delete posts one ID per request; direct updateField has no dedicated call in this page.

Related endpoints