Goods returns
Delete mapped return-note headers
/a/GoodReturned_delete
Delete matching return headers and record deletion history, without deleting their lines.
When to use this endpoint
Used by CRM2’s goods-return table deletion. Prefer one exact ID and do not assume this reverses a goods-return transaction.
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 | One filter required | Recommended exact ID selector; a native array matches IDs in that list. This helper does not use the ids alias. |
Other mapped aliases | Scalar or native array | Alternative filters | Any mapped column can restrict deletion. Text uses exact equality or membership (not trimmed substring search); numeric scalars use intval and numeric arrays use typed conversion. Different aliases are ANDed. Broad filters can delete multiple records. |
Example request
FM_api('GoodReturned_delete', ['id'=>642]);
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 filter"} | No recognized mapped column filter was supplied. |
{"error":"Could not read records for deletion. Please retry."} | Selecting the rows fails. |
{"error":"Could not delete records. Please retry."} | The physical delete query fails. |
{"error":"Could not record deletion audit."} | Deletion already happened, but recording its audit failed. Retrying cannot restore those records. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- This table is not in DataProcessClass’s soft-delete table set: the helper physically deletes rows, not
deleted=1. No migration is performed by the request. - No matching records is a successful
{"ok":1}. Unknown keys are ignored; at least one recognized filter is still required. - Reads, deletion and audit are separate operations, not a transaction. Do not treat deletion success as recoverable soft deletion.
- Header deletion leaves goods_returned_entries untouched and does not restore stock. A previously deducted quantity stays deducted.
Side effects
- Invalidates goods_returned cache. Records matched IDs/rows in the tenant deletes audit through the shared helper and writes a Core_log delete event after deletion.
- Does not remove child lines, change purchase orders/received notes or recompute stock.
See it in Fieldmotion
CRM1
CRM1’s goods-return pages use the legacy GoodsReturned/GoodsReturnedNote calls instead of this mapped operation.
CRM2
CRM2’s goods-return layouts use the goodReturned mapping in php/Layout/_map.php: create/read/update are GoodReturned_createData, GoodReturned_getLayoutDetails and GoodReturned_updateData. The table uses GoodsReturned_getDataTable; its delete action calls GoodReturned_delete.