Goods Received
Create a mapped receipt line
/a/GoodsReceivedEntry_createData
Insert receipt-line metadata without receiving stock.
When to use this endpoint
Insert receipt-line metadata without receiving stock.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. Session CSRF, account-active and IP restrictions still apply. These handlers add no receipt-specific page, finance, department or record-owner permission check.
Records are scoped to the authenticated tenant. CRM1 displays Goods Received with employer feature bit 262144; CRM2 checks features2.goodsReceivedNotes. Those screen gates are not enforced by these handlers. Mobile receipt routes run separately through the mobile intermediary and have different permission and ownership checks.
Mapped handlers require both a logged-in user and a tenant context before loading the tenant field map.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
grnID | Integer | No | Receipt-header ID, integer-coerced. Parent existence is not validated by this mapped write. Supplier belongs to the header, not this line map. |
stock | Native object | No | Composite {id,type,text} expands to stockID, stockType, stockText. UI uses type 1 catalog stock and 2 free text; the server does not validate that enum or the catalog record. |
stockID, stockType, stockText | Integer / text | No | Direct composite components. Text replaces stock_text; IDs use intval. The line retains the provided description rather than looking up a current stock name. |
qty | Decimal | No | Non-negative amount delivered, up to four decimal places after tenant upgrade 798. Invalid, negative, non-finite, excessively large or over-precision input is rejected. This metadata-only write does not move stock. |
cDate, lastEdited | Date/time string | No | cDate defaults to server now on creation. Edit timestamps are automatically added. Datetime strings are not strictly validated; blank becomes SQL NULL. |
meta | JSON text or native object | No | Whole meta replacement; no schema validation or merge. |
metaReference, metaStorage | Text or native structured value | No | Nested meta.reference / meta.storage aliases preserve other metadata. The receipt workflow stores reference as an array and storage as an ID; this map labels both text. |
noRecord, noRecordCustom | Native arrays | No | History-hidden controls, not a way to skip persistence or permissions. |
Example request
FM_api('GoodsReceivedEntry_createData', ['grnID'=>'531', 'stock'=>['id'=>'318','type'=>'1','text'=>''], 'qty'=>'2']);
Example response
{"ok":1,"id":"701"}
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":"Unable to create record"} | Database persistence failed; bulk updates may already have committed a prefix. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Mapped integer fields use intval; UI hidden/readonly metadata is not a server authorization rule. Unmapped keys are ignored. The literal string
nullis treated as SQL NULL even for ordinary text, while omitted/null keys are generally skipped by isset. - Only cDate defaults in the line map; last_edited is added automatically. No parent, stock, supplier or qty is required by the map, so a minimal request can create an unlinked zero/default line.
- Direct po_id and poe_id are not mapped aliases and are ignored. Former supplierID/grne_id/grt_id aliases are also unmapped; they cannot write nonexistent line columns.
- Neither route creates inventory, movement history, PO fulfillment calculations or catalog quantity changes. Updating grnID can move a line between headers without ownership/parent checks.
- The line map has no supplierID, grne_id or grt_id fields. Those former aliases referenced nonexistent columns and were removed; supplier linkage is stored on the header. Default all-field reads now use the actual receipt-line schema.
Side effects
- Mapped line insert/update, purchases_in_entries cache invalidation, edit timestamp and field history; no catalog/inventory movements.
See it in Fieldmotion
CRM1
No direct CRM1 caller was found. CRM1 uses the legacy GoodsReceived_newNote, GoodsReceivedEntries_get and GoodsReceivedNote_* workflow instead.
CRM2
CRM2 receipt widgets request goodsReceivedEntry through the layout helpers. Layout/_map.php names GoodsReceivedEntry_getLayoutDetails as the child reader, but that handler file is absent. Direct GoodsReceivedEntry_getRequestedDetails exists; do not promise that every nested layout read resolves.
Related endpoints
GoodReceived_createData— actual CRM2 receiving workflow.GoodsReceivedEntry_getRequestedDetails— verify selected line fields.