When to use this endpoint

Build CRM2 export rows for an explicit set of Goods Received IDs.

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.

Parameters

ParameterTypeRequiredDescription
_idsJSON array textYesNonempty JSON array; items intval-coerced. Native arrays and the _ids=1 discovery convention are not supported.
fieldsJSON array textYesNonempty JSON list of strings: id, supplier_id, tax_id, cdate, po_id, reference, po_num, po_cdate, supp_invoice, supp_dnn, notes, last_edited, totalNet. Native lists, objects, malformed JSON and non-string field names are rejected before field processing.

Example request

FM_api('GoodsReceived_getExportData', ['_ids'=>json_encode(['531']),'fields'=>json_encode(['id','supplier_id','totalNet'])]);

Example response

[{"pi_id":"531","f0":"531","f1":"Parts supplier","f2":"25.00"}]

pi_id is always the receipt ID. f0/f1/... correspond to original fields positions; no human labels or CSV header are returned. A calculated no-PO totalNet is numeric rather than a database decimal string.

Errors and unusual responses

ResponseCondition
{"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: _ids"}_ids omitted.
{"error":"_ids should be a JSON array of numbers"}Decoded IDs are empty/not an array.
{"error":"fields should be an array of requested field names"}fields is missing, malformed, empty, not a JSON list or contains non-string names.
{"error":"unknown field name: unknown"}A requested ordinary alias is not in the export allowlist.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • IDs are selected with IN, ordered ascending by receipt ID; duplicate IDs do not duplicate rows and missing headers are omitted. No pagination or ownership filter.
  • supplier_id exports the supplier name. Repeated supplier_id and totalNet aliases receive the same transformed value at every requested fN position.
  • totalNet uses the entire linked PO total_net, not the portion received. Only when that value is NULL/missing does it sum amt_delivered × current catalog average_cost. Free-text lines have no catalog join and do not contribute to the fallback.
  • Colon-style custom field tokens are parsed and skipped but never populated; they can leave gaps in fN positions. target_id requests first append target_type but neither is allowlisted, so those export fields fail rather than producing target labels.
  • No active/deleted linked supplier/stock/PO filter is applied. A failed primary export query returns goods receipt export failed.

See it in Fieldmotion

CRM1

No CRM1 caller was found; its Goods Received Export button uses the CSV endpoint directly.

CRM2

Goods Received → Export uses widgetExportCRM2 type 44 after collecting IDs with GoodsReceived_getDataTable. Inspect the signed request for JSON-encoded _ids and fields.

Related endpoints