When to use this endpoint

Stream a CSV of receipt headers and linked purchase-order totals.

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
grnIDIntegerNoNonzero integer selects one header; zero omits the filter. No positive-only validation.
daysFrom, daysToInteger day offsetsNoRelative to server today at midnight. Lower bound inclusive; upper bound exclusive at daysTo+1. Blank values omit their bounds. Not dateFrom/dateTo strings.
searchStringNoTruthy substring search on receipt ID, supplier name or PO ID. No PO number, invoice-reference or notes search.
notesStringNoSeparate lowercase substring notes filter. Quotes are escaped as data; LIKE wildcards (% and _) retain their search meaning.

Example request

FM_api('GoodsReceived_export', ['grnID'=>'531']);

Example response

GRN#,Supplier,"Supplier Tax No",PO#,"Total Net",Reference,"PO Date","Date Received",Notes
531,"Parts supplier",VAT-123,482,25.00,STORES,"2026-10-01 09:00:00","2026-10-09 00:00:00",Checked

The body is CSV, not JSON. Download headers specify text/csv and filename goods_received.csv. There is always a header row; with no matches there are no data rows.

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":"goods receipt export failed"}Query or temporary-stream preparation failed.

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

Behaviour and edge cases

  • Rows are ordered by receipt ID ascending, with no pagination/cap. Filters are ANDed. Joins do not hide inactive/deleted suppliers or POs.
  • PO# is the internal PO ID, not po_num. Total Net is the full linked PO total; a receipt without a PO has no calculated receipt-line fallback here.
  • Supplier Tax No uses the selected supplier tax_id; missing tax IDs remain blank.
  • CSV is assembled in a request-local temporary stream, so concurrent requests do not overwrite a shared tenant filename. Query/stream failures return goods receipt export failed before download headers.
  • CRM1 hides Export when permissions bit 256 is set, but the handler itself requires a logged-in user and tenant context. That UI restriction is not server-enforced.

Side effects

  • Uses a request-local temporary stream and terminates the request after downloading; no business-data writes or shared tenant CSV file.

See it in Fieldmotion

CRM1

Open Goods Received โ†’ Export (if visible). The UI posts a form with daysFrom/daysTo/search and _csrf to GoodsReceived_export; inspect the downloaded CSV response.

CRM2

CRM2 uses GoodsReceived_getExportData through widgetExportCRM2 instead of this direct download.

Related endpoints