Customers
List completed customer jobs with stock
/a/Customer_stockGetDT
Return completed direct-customer jobs and their main-form or table-form stock payloads for the CRM1 Stock Used table.
When to use this endpoint
Use Customer_stockGetDT for the paged CRM1 Stock Used tab when each row must remain tied to a completed job and assigned user.
Use Customer_stockTotalsGet when only quantities aggregated by stock name are needed.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.
The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cid | Integer string | Yes | Customer ID. Presence is validated, but positivity and customer existence are not. Only direct-customer jobs are queried. |
start | Integer string | Yes | Zero-based row offset. |
length | Integer string | Yes | Page size. |
draw | Integer string | No | DataTables counter copied to the response; defaults to 0. |
dateFrom | Date/time string | No | Inclusive completed-time lower bound converted from tenant-local time to epoch. When present, dateTo is also consumed. |
dateTo | Date string | With dateFrom | Inclusive tenant-local completed-time upper bound through 23:59:59. It has no effect without dateFrom. |
job_id | Integer string | No | Exact job ID. Zero and blank do not filter. |
stock | String | No | Find stock IDs whose name, code, or description contains this text, then match those IDs inside the job’s main stock_used JSON text. Table-form stock is not searched by this filter. |
username | String | No | Find assigned user IDs whose name contains this text. No matching user forces an empty result. |
Example request
$rows = FM_api('Customer_stockGetDT', [
'cid' => '1088',
'start' => '0',
'length' => '25',
'draw' => '14',
'dateFrom' => '2026-09-01',
'dateTo' => '2026-09-30',
'username' => 'Aoife',
'stock' => 'filter',
]);
Example response
{
"draw": 14,
"recordsTotal": 3,
"recordsFiltered": 1,
"data": [
["7204", 1727175600, "36", [[{"id":"211","amt":"2","cost":12.5}], {"id":"212","amt":"1"}]]
]
}
Each row is job ID, completed-time epoch as an integer or blank string, user ID, and a heterogeneous stock array. Main stock_used is appended as one decoded array; stock found in table-form fields is appended item by item.
The exact stock objects preserve their stored fields, which can include id, amt, containers, cost, source, and link metadata.
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: start"} | start is absent. |
{"error":"missing or invalid parameter: length"} | length is absent. |
{"error":"missing or invalid parameter: cid"} | cid is absent. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Rows require a non-zero completion state,
customer_type=0, the requested customer ID, and a non-deleted job. They are always ordered by completion epoch descending; request ordering fields are ignored. - Table-form extraction walks every encoded field containing a
stockmember and does not consult the form definition or field type. Malformed JSON is skipped or can generate legacy warnings depending on its shape. - The
activevalue sent by CRM1 is not read. Customer activity and deletion state are not checked.
See it in Fieldmotion
CRM1
Open a customer and select Stock Used. Filter Network requests for Customer_stockGetDT; date, job ID, user-name, stock-text, and paging controls reload the table. CRM1 also sends active, which the handler ignores.
CRM2
CRM2 does not call this endpoint for its Stock Used table; it uses a newer CustomersStock_getDataTable flow and calls other endpoints in this family for totals and export retrieval.
Related endpoints
Customer_stockGetExportDataimplements the two-phase row export used by CRM1 and CRM2.Customer_stockTotalsGetsums customer stock quantities by current stock name.Customer_stockExportTotalsdownloads a simpler main-stock-only totals CSV.