Stock catalog fields and lookups
Resolve stock IDs to names and codes
/a/Stock_listByIds
Hydrate a chosen set of non-deleted stock IDs as id/name/code object rows.
When to use this endpoint
Use to resolve stock names/codes when a saved document already contains local IDs. Archived stock is included, but deleted items are omitted rather than offered for reuse.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. This handler requires both a user identity and tenant context; it adds no stock-page, finance or administrator permission check.
All queries use the authenticated tenant. API signing and session CSRF checks still apply; see Getting started.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ids | Native array or JSON array text | Yes | Native array or JSON-decoded string array. Each scalar member is integer-converted; malformed JSON, non-array input and nested members are rejected. Empty array returns []. |
Example request
$items = FM_api('Stock_listByIds', ['ids'=>json_encode(['1042','1043'])]);
Example response
[{"id":"1042","name":"Filter cartridge","code":"FLT-01"}]
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: ids"} | ids absent/null, malformed JSON/non-array, or a non-scalar array member. |
[] | Empty ID array or no matching rows. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Requires login and tenant context before parsing IDs or returning an empty array.
- Filters deleted=0 but not is_archived. Missing/deleted IDs are omitted, duplicates collapse through SQL IN and input order is not preserved. No ORDER BY or pagination.
- Exactly id,name,code are returned; no fields, availability, owner or department restriction.
- No direct mobile caller was found in the current app JavaScript or
m/wwwintermediary. The app receives stock throughsyncDownloads, which selects non-deleted stock by edit timestamp; these calls are not the app synchronization protocol.
Side effects
- Read-only; no audit, edit timestamp, event or stock movement.
See it in Fieldmotion
CRM1
Saved quote/job-table selectors and the shared getStockName helper batch IDs through this endpoint. Filter Stock_listByIds while a saved stock label is resolved; the helper sends JSON text ids.
CRM2
The CRM2 shared getStockName helper also sends JSON ids and builds name/code labels. This is independent of the mapped Stocks table.
Related endpoints
Stock_listByCategoryprovides an active, unarchived picker.Stocks_getByCodefinds stock when the caller has codes rather than IDs.