Goods returns
Read mapped return lines for a layout
/a/GoodsReturnedEntry_getLayoutDetails
Read mapped return-line fields through the reader configured for CRM2 layouts.
When to use this endpoint
Delegates to GoodsReturnedEntry_getRequestedDetails with identical authentication, selection, validation and response shape. CRM2 Layout_getValue resolves this route from the goodsReturnedEntry mapping.
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 / ids | Integer or native array | No | Restrict return IDs; id wins over ids. Each ID is integer-converted. An omitted selector or empty ID array does not restrict the lookup. |
fields | Native array of strings | No | Mapped field aliases to return; omitted means every mapped field. Unknown fields are ignored and id is always included. Do not pass a JSON-encoded string. |
Mapped field filters | Scalar or native array | No | Other mapped aliases are ANDed: text/date/JSON scalar values use lowercased, trimmed equality, arrays use membership. Numeric filters use integer conversion, including mapped decimal/float values. Non-numeric numeric-array members are discarded; an empty usable numeric list matches nothing. |
order | Alias or native array | No | One alias, a list of aliases, or entries {id:"cDate",dir:"desc"}. Unknown aliases are ignored; only exact desc gives descending order. No default ordering. |
advanceSearch | Native array | No | Native structured conditions: exact mapped id/column, allowlisted condition, scalar/scalar-list value, optional AND/OR andOr and ( or ) special. Raw where is rejected. |
Entry aliases | Field names | For fields/filters | id, grtID, grnID, stockType, stockID, stockText, stock, qty, cDate, lastEdited and grne_id. grtID/grne_id are integer-mapped. Selecting stock also projects component aliases. |
Example request
FM_api('GoodsReturnedEntry_getLayoutDetails', ['id'=>744, 'fields'=>['stock','qty']]);
Example response
[{"stock":{"id":"1042","type":"1","text":null},"qty":"2","stockID":"1042","stockType":"1","stockText":null,"id":"744"}]
Composite stock is assembled from saved stock_id/type/text, not looked up in the stock catalog. The component aliases are included as well. Catalog names and original purchase unit costs are not added.
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":"unsupported raw advanced search"} | A rule contains where instead of an allowlisted mapped structured condition. |
{"error":"missing or invalid parameter: orderDesc"} | Direction is not asc/desc. |
{"error":"missing or invalid parameter: fields"} | fields must be a native string array. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Returns an array even for one ID; no match is
[]. A failed database read is also collapsed to[]rather than a distinct database error. - No offset, length, limit or DataTables counters are implemented by this reader. An unfiltered call can return the entire tenant table.
- Stored database scalar types are preserved, commonly numeric strings and SQL NULL as JSON null. JSON columns remain JSON-encoded strings; there is no automatic decoded custom object.
- There is no supplier name enrichment, deleted/archived related-record filtering or line/stock reconciliation.
- A stock filter object expands supplied id/type/text members to the scalar aliases, which are ANDed. It is not a native list of catalog IDs; use stockID for that.
- No parent-header existence check: orphan lines left behind by header deletion can still be read by grtID.
- Native filter shapes and structured advanced-search/order controls are validated before the helper executes. Raw SQL is not supported.
Side effects
- Read only. Does not reconcile catalog stock or derive costs.
See it in Fieldmotion
CRM1
CRM1’s return-note view calls GoodsReturnedEntries_get for tuples rather than this mapped detail reader.
CRM2
CRM2’s GoodsReturnedEntry_getLayoutDetails now delegates to this reader. Layout_getValue for a goodsReturnedEntry layout reads these fields. Parent header reads still do not expand nested widgets automatically.