Suppliers
Update stock-supplier fields
/a/StockSupplier_updateData
Patch mapped fields on one or more existing stock-to-supplier relationship rows.
When to use this endpoint
Use StockSupplier_updateData to change cost, price, part number, or another mapped value without replacing the stock item’s complete supplier list.
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 |
|---|---|---|---|
id | Integer-compatible or array | Yes | Relationship-row ID. The shared updater accepts either one ID or a native array. |
name | String | No | Relationship label, normally copied from the stock item name. |
stockID | Integer-compatible | No | Stock item ID. The endpoint integer-converts it but does not verify that the stock item exists. |
supplierID | Integer-compatible | No | Supplier ID. The endpoint integer-converts it but does not verify that an active supplier exists. |
locationID, qty | Integer-compatible | No | Optional location and quantity values, converted with intval(). |
cost, price | Numeric-compatible | No | Per-unit cost and price, converted with floatval(). |
partNumber | String | No | Supplier-specific part number. |
lastEdited | Unix timestamp or date string | No | Stored as a Unix timestamp. Creation defaults to the current server time; a nonnumeric value is parsed with strtotime(). |
Example request
$result = FM_api('StockSupplier_updateData', [
'id' => '9021',
'cost' => '13.25',
'price' => '19.50',
'partNumber' => 'NS-8201-B',
]);
Example response
{"ok":1}
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: id"} | id is absent. |
Field-specific validation error | A supplied mapped value cannot be converted or validated. |
{"ok":1} | The ID is unknown or no writable fields are supplied; this shared updater does not return not-found. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Only supplied mapped fields are changed. Omitted fields remain untouched.
- A native ID array updates each row in turn. Individual failures are discarded and the wrapper returns
{"ok":1}after the loop, so scalar IDs are safer for error handling. - Normal changes advance
lastEditedto the current server Unix timestamp unless that field is explicitly supplied. - The table has no soft-delete state; every matching row is directly updated.
Side effects
- Changed fields are recorded in Core history and the
stock_supplierscache is invalidated.
See it in Fieldmotion
CRM1
No dedicated CRM1 caller was found; the legacy Stock editor normally replaces the complete relationship list.
CRM2
CRM2 generic mapped controls can use this route for individual relationship-row edits.
Related endpoints
StockSupplier_createDatacreates one relationship.StockSupplier_deleteDatapermanently removes matched relationships.