Suppliers
Query stock-supplier relationships
/a/StockSupplier_getRequestedDetails
Read stock-to-supplier relationships with selectable mapped fields, exact filters, optional ordering, and an archived-stock toggle.
When to use this endpoint
Use StockSupplier_getRequestedDetails to load supplier pricing/part-number associations for stock items or all associated stock for a supplier.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler calls the normal login guard but performs no additional Suppliers-page, stock, purchasing, role, create, edit, or delete permission check.
All records are selected from the authenticated tenant. CRM1 and CRM2 hide some controls through client-side permissions, but these endpoints do not repeat those UI checks.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fields | Native array | No | Mapped fields to return. Omission requests every mapped field. Available names are id, name, stockID, supplierID, supplier, locationID, qty, cost, price, partNumber, and lastEdited. |
id or ids | Integer-compatible or native array | No | Relationship-row IDs. id takes precedence when both are present. |
Mapped field filters | Scalar or native array | No | Any mapped field can filter. Text values are case-insensitive exact matches; numeric values are integer-converted. Common filters are stockID and supplierID. |
order | Mapped field, field object, or native array | No | Optional ordering; objects use {"id":"cost","dir":"desc"}. |
showInactiveStock | Integer-compatible | No | Exact integer 0 joins the stock table and excludes archived stock. Omission or any nonzero value includes associations for archived stock. |
Example request
$rows = FM_api('StockSupplier_getRequestedDetails', [
'fields' => ['id', 'stockID', 'supplierID', 'name', 'cost', 'partNumber'],
'supplierID' => '488104',
'showInactiveStock' => '0',
'order' => [['id' => 'name', 'dir' => 'asc']],
]);
Example response
[
{"id":"9021","stockID":"8201","supplierID":"488104","name":"Northshore Components","cost":"12.50","partNumber":"NS-8201"}
]
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. |
[] | No relationship matches every filter, or active-only mode excludes the associated stock. |
Runtime/type error | fields is supplied as a string rather than the native array consumed by the shared reader. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- There is no pagination or implicit row limit.
- The relationship table has no deleted flag. When active-only mode is enabled, the inner join also drops associations whose stock row is missing.
- Requesting
supplierreturns a nested display object assembled from the linked non-deleted supplier. A missing/deleted linked supplier does not remove the main relationship row because that display join is left-joined. lastEditedis returned as a SQL datetime converted from the stored Unix timestamp.- Unknown requested field names are silently omitted;
idis always included.
See it in Fieldmotion
CRM1
Supplier cost/price screens query associations by supplier or stock ID and can toggle whether archived stock is included.
CRM2
Open the supplier price/cost adjustment list or a Stock item’s supplier controls. CRM2 calls this route and sends showInactiveStock=0 until the archived-stock option is enabled.
Related endpoints
StockSupplier_setSuppliersreplaces a stock item’s relationship rows.Supplier_getRequestedDetailsreads Supplier master records.