Goods returns
Patch mapped return lines
/a/GoodsReturnedEntry_updateData
Change saved return-line fields without reconciling stock, costs or the parent header.
When to use this endpoint
Use for a partial mapped line patch. Changing qty or stockID here does not undo or recompute the stock subtraction performed by legacy GoodsReturned_new.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. Session CSRF and account/IP restrictions still apply. These handlers add no goods-return, finance, department, owner or page-role permission check.
Records belong to the authenticated tenant. CRM1 shows this workflow when the employer features bit 262144 is enabled; CRM2 uses features2.goodsReturnedNotes. These are UI gates, not checks performed by these handlers.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer or native array | Yes | Line ID, not parent/header ID. A native array applies the same patch independently to each line. |
grtID | Integer | No | Positive whole parent return-note ID when supplied; parent existence is checked. Optional for metadata-only line creation. |
grnID | Integer | No | Whole positive goods-received note ID or legacy -1. Required on header creation; optional on updates/line creation. No received-note existence or supplier ownership check. |
stock | Native object | No | Native {id,type,text} expands to scalar stockID/type/text; present members, including zero/empty, override scalar aliases. Not a stock movement. |
stockID / stockType | Integer | No | stockID must be a non-negative whole integer; stockType must be 1 (catalog) or 2 (free text). No catalog availability validation by mapped writes. |
stockText | String | No | Free-text description, persisted separately from catalog stock. |
qty | Integer | No | Whole non-negative 32-bit integer; negatives and fractions are rejected. Mapped edits do not reconcile stock or impose a received-quantity maximum. |
grne_id | Integer | No | Whole integer goods-received entry link with this exact name. No received-entry relationship validation. |
cDate | Date/time string | No | Exact YYYY-MM-DD HH:MM:SS without timezone conversion. Defaults to server now on creation. Blank/null becomes SQL NULL; writable despite UI readonly metadata. |
lastEdited | Date/time string | No | Server-owned edit time; supplied values are ignored. Creation and changed updates set last_edited to server date/time. |
noRecord | Native array | No | Native field-alias list whose history is marked hidden on create/update; does not skip persistence/history or grant authorization. |
Example request
FM_api('GoodsReturnedEntry_updateData', ['id'=>744, 'qty'=>3, 'stockText'=>'Updated packaging']);
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":"goods return write failed"} | A primary write or history insert failed; the transaction is rolled back. |
{"error":"goods return read failed"} | A required locking read failed; no changes commit. |
{"error":"goods return transaction failed"} | Starting/committing the tenant transaction failed. |
{"error":"goods return operation failed"} | Unexpected database/JSON processing failure; no changes commit. |
{"error":"missing or invalid parameter: id"} | Missing/malformed positive selector. |
{"error":"goods return record does not exist"} | Any bulk target is missing; the whole patch is rejected before writes. |
{"warning":"no updated fields."} | No editable values supplied. |
{"warning":"No Change."} | Multi-field values unchanged. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Primary writes and history commit in one checked tenant transaction. A failed read, write or history insert rolls back the operation; individual bulk failures are not concealed.
- Primary IDs are immutable. Numeric amounts must be finite; integer fields must be whole 32-bit values. Quantities and stock/supplier IDs cannot be negative. Received-note references accept positive integers or legacy -1.
- Updates are partial patches; omitted values remain unchanged. Date/time strings must be exact YYYY-MM-DD HH:MM:SS, with blank/null stored as SQL NULL. customValues must be valid JSON/native JSON and replaces the complete value. Ordinary text "null" is preserved as text.
- Presentation readonly/hidden flags generally do not restrict header writes: dates, totals and delivery values remain writable. lastEdited is server-owned; supplied values are ignored.
- Line edits do not reconcile catalog stock/warehouse containers, calculate totals or touch header timestamps. A supplied grtID must refer to an existing parent. No supplierID alias is mapped.
- A native ID array applies the same patch transactionally after every positive ID is found. Empty ID arrays succeed without writes. No optimistic lock is enforced.
- Composite stock members override scalar aliases, including zero/blank, on create and update. Supplied stockType must be 1 or 2. qty rejects fractions rather than truncating. grtID and grne_id are integer-mapped.
Side effects
- Changed writes advance last_edited, invalidate the table cache and atomically record field history. noRecord hides named field history; noRecordCustom hides named custom-key history. Neither skips persistence or removes history.
- No notification, PDF generation, accounting export or warehouse/container movement.
See it in Fieldmotion
CRM1
CRM1’s goods-return pages use the legacy GoodsReturned/GoodsReturnedNote calls instead of this mapped operation.
CRM2
CRM2’s goodsReturnedEntry mapping uses this family. Its configured GoodsReturnedEntry_getLayoutDetails now delegates to the authenticated safe detail reader; Layout_getValue resolves it.