Stock exports and reporting
Fetch selected stock summary columns
/a/Stock_exportSummaryData
Fetch stock summary rows using positional export-field aliases.
When to use this endpoint
Use when a caller already has selected stock IDs and needs a JSON field projection. This is not the CSV Summary report or a generic mapped export.
Authentication and permissions
Authenticate with a signed API-key request or a logged-in CRM session. Requires Stock view (pageStocks_view) and table export (pageMain_exportTableData) permissions through the shared export guard; denial returns permission denied.
Client administrators and the all permission satisfy the checks. Legacy users with no role use the helper’s allow fallback when no explicit permission list is loaded. This is not merely the CRM1 export-button bit check.
Queries use the authenticated tenant. No department/owner restriction or stock-tracking feature gate is added by these handlers. CRM2 features2.stockTracking changes the export choices offered, not server authorization. Session CSRF and API signing still apply.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
_ids | JSON string containing a non-empty array | Yes | Must be a JSON string decoded to a non-empty array; members integer-convert. [] and scalar JSON are rejected; native arrays return the array-format error. |
fields | JSON string containing a non-empty array | Yes | Allowed names: stock_id,name,code,warehouse,customer,job,user,vehicle,jobDispatch,userDispatch,vehicleDispatch. Each requested index k becomes f{k}. stock_id is always also included. Colon custom-field tokens are skipped and do not load custom data. Must be a positional JSON list of strings, not an object or nested values. |
Example request
$rows = FM_api('Stock_exportSummaryData', ['_ids'=>'[1042]', 'fields'=>'["code","warehouse","user"]']);
Example response
[{"stock_id":"1042","f0":"FLT-01","f1":"7","f2":2}]
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":"permission denied"} | Either required export permission is denied. |
{"error":"missing or invalid parameter: _ids"} | _ids omitted (checked before login). |
{"error":"_ids should be a JSON array of numbers"} | _ids decodes to an empty array, falsey value or non-array. |
{"error":"fields should be an array of requested field names"} | fields missing, malformed, empty, non-list or containing a non-string. |
{"error":"unknown field name: example"} | An unrecognized non-custom field is requested. |
{"error":"invalid parameter: stockIDsFilter"} | A supplied selected-ID list is not a string of positive decimal IDs. |
{"error":"invalid parameter: search"} | A supplied stock/date filter is an array or other non-scalar value; the error names that parameter. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Excludes deleted stock but includes archived stock. The response always contains stock_id plus f0,f1,... aliases for non-custom requests; example fields are [code,warehouse,user].
- Customer/job/user/vehicle and dispatch fields start as empty strings when no matching container type exists, not numeric zero. Found aggregates preserve fractional sums.
- Repeated aggregate and direct stock fields populate every requested alias.
- Colon-delimited custom field tokens are collected or skipped but never hydrated; there is no custom table query. Do not expect values from apparently accepted custom tokens.
- Container aggregates are read tenant-wide despite the selected-stock projection. No pagination/date controls or alternate _ids=1 discovery mode is supported.
- No pagination or result limit is implemented. Missing stock IDs are omitted and no ordering is promised.
- No stock quantity, audit, edit timestamp, notification or event is changed. Reads across multiple queries are not a transactionally frozen snapshot.
- No direct caller for this exact endpoint was found in the current app JavaScript or
m/wwwintermediary; these are office reporting/source-selection calls, not the app download protocol. - The shared guard rejects non-scalar supplied stock/date filters and validates any supplied stockIDsFilter even on reports that do not use it for selection.
Side effects
- Read-only; no downloadable file is created.
See it in Fieldmotion
CRM1
No direct CRM1 caller for this exact endpoint was found; warehouse/cost exports use their dedicated CSV handlers.
CRM2
No direct CRM2 caller for Stock_exportSummaryData was found; Stocks CSV Summary uses Stock_exportSummary.
Related endpoints
Stock_exportSummaryprovides the CSV destination-type summary.Stock_getCostsprovides single-item costing defaults.Stock_getNamesresolves catalog labels.