When to use this endpoint

Use for CRM2 User/Vehicle stock tables. Keep owner identity and source type in scope rather than treating grouped rows as a stock ledger total.

Authentication and permissions

Authenticate with a signed API key or a logged-in CRM session on the account’s routed host. Signed requests act as the key owner. Session requests must include the dispatcher CSRF value when configured. All record identifiers belong to the authenticated tenant.

The dispatcher and these handlers do not impose an additional CRM2 Stock role or Stock TeamAccess record scope. CRM2 screen permissions are separate controls and must not be assumed to apply to CRM1. These routes do not become public because an individual legacy handler checks only the tenant context.

Parameters

ParameterTypeRequiredDescription
fieldsNative field-name arrayYesMapped names: id, stockID, containerID, containerType, container, qty, amtTrigger, lastEdited, inventoryID, meta, metaInventory, stockNameOrder and stockCodeOrder. Use a nonempty native list, not JSON text.
start / length / drawInteger-compatibleNoDefaults 0/10/0. No wrapper page-size maximum.
orderBy / orderDesc / orderMapped name/direction or native DataTables orderNoExplicit mapped name and asc/desc, or DataTables column/direction. Equal sort values have no guaranteed order.
isTable / limit / groupByInteger-compatible / native field listNoisTable=0 returns unpaged {data}; positive limit caps that mode. groupBy changes SQL grouping, not aggregate sums.
Mapped filters / searchField / searchValue / advanceSearchScalars/native arraysNoUse mapped fields and typed rules. Raw SQL where rules are refused.
referenceDate / dateFrom / dateToMapped date field / relative day offsetsNoPaired day offsets use account-local today and inclusive bounds; omission leaves the date window unset.
offsetFrom / offsetTo / timeRangeFrom / timeRangeToNative offset objects / hoursNoOffsets use hour/minute keys. The optional hourly filter needs timeRangeFrom; see the legacy behavior below.
stockName / stockCode / stockIsArchivedText / native archive listNoOptional joined catalogue filters. Name/code are quoted case-insensitive substring patterns; archive is a native0/1 list. Supplying these keys joins undeleted stock; malformed shapes and archive values are rejected.
qtyAllocated / qtyDispatchDerived field names inside fieldsNoRequesting either groups per stock,logical owner and source family. 1/14 User,2/20 Vehicle and7/18 Job share their respective family; other types remain separate. Both totals and stockID/container are included.

Example request

$page = FM_api('StockContainers_getDataTable', ['fields'=>['id','stockID','qty','container'],'containerID'=>'1088','start'=>'0','length'=>'10','draw'=>'1']);

Example response

{"data":[{"id":"2081","stockID":"1042","qty":"3","container":{"id":"1088","type":"1"}}],"draw":1,"recordsTotal":"12","recordsFiltered":"1"}

Examples show one representative result; database numeric scalars can be JSON strings. Application errors can use HTTP 200: inspect error and warning in the decoded response.

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":"invalid advanced search"}Raw where SQL in advanceSearch.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • The default response is {data,draw,recordsTotal,recordsFiltered}. data contains named mapped fields; database numeric values normally remain strings. draw is integer-converted. There is no automatic active-stock/owner filter on these ledger tables.
  • Table mode defaults to start=0,length=10; there is no wrapper maximum. isTable=0 removes table paging and count/draw fields, leaving {data}; positive limit then caps rows. Use native arrays for fields, groupBy, picker filters and advanceSearch.
  • Mapped filters, searchField/searchValue and typed advanceSearch combine with endpoint filters. Use mapped names (or the shared table_column advanced-search IDs), never SQL fragments; a rule with raw where SQL returns invalid advanced search.
  • referenceDate selects a mapped date field. Paired dateFrom/dateTo are integer day offsets from today in the account timezone setting (UTC fallback), with inclusive start/end-of-day bounds. Optional offsetFrom/offsetTo contain hour/minute adjustments: hours are negated, minutes added. These are relative-day controls, not literal date strings.
  • Legacy hourly filtering is activated by timeRangeFrom (default range ends at 23; timeRangeTo alone does not activate it). It uses the selected date field and timezone setting, with Europe/London as that branch’s fallback. Prefer explicit typed date rules when reproducible absolute boundaries are required.
  • orderBy=stockName/stockCode maps to dedicated joined sort fields, so visible catalogue names/codes determine order. No deleted-stock condition is added by these sorting joins.
  • Grouped views SUM each allocated/dispatched bucket, preserve different owners/families and combine numeric/UUID vehicle aliases. Counts and pagination operate on groups after filtering. An explicit containerType selection restricts source rows before aggregation; the representative row supplies id,threshold and other ordinary fields (qty itself is not a derived total).
  • Grouped recordsTotal counts the selected source-type family groups before ordinary filters; recordsFiltered counts groups after those filters. Ordinary raw-row mode remains available when neither derived total is requested. Grouped mode owns its grouping; an incoming groupBy does not replace it.
  • Vehicle container output contains the logical numeric ID and correct uuid for both type2/type20. Native query controls are validated, text filters remain quoted and stable pagination uses allocation ID as a tie-breaker.
  • In raw mode, an explicit groupBy remains SQL grouping rather than a quantity sum; use the derived total fields when an allocated/dispatched aggregate is required.

Side effects

  • Database reads only; no reservation, movement, alert or history entry is created.

See it in Fieldmotion

CRM1

No direct CRM1 caller was found in the source search. CRM1 uses its legacy Stock grid and stockContainerEdit allocation editor instead.

CRM2

Open CRM2 User Stock, Vehicle Stock or All User Stock. Their displayTable prefixes StockContainer/StockContainers select this table route; filter Network for StockContainers_getDataTable. Name/Code header sorting uses the related catalogue values.

Related endpoints