When to use this endpoint

Use CRM1’s line-item export when it needs fixed columns. The modern selected-field JSON counterpart is PurchaseOrders_getExportLineItemsData.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session. Session requests use dispatcher CSRF protection when configured. API keys use their owner’s identity.

Purchase Order View is required on the singular or plural page. Records must be active and inside the configured TeamAccess or legacy Department Based Filter boundary; administrators are exempt from record restrictions. API-key requests use their owner’s identity. Related display names require the corresponding page View and record visibility.

Parameters

ParameterTypeRequiredDescription
daysFromRelative day stringYes (presence)Required key; blank is accepted and disables the lower creation-date bound. Nonblank values must be integer server-today offsets.
daysToInteger-compatible relative daysNoOptional upper relative day; nonblank integer offsets include the complete selected server day. Blank/omission adds no upper bound.
searchTextNoOptional legacy substring search. The exact searched columns differ by export; LIKE wildcards retain meaning.
rawAny present valueNoPresence suppresses Content-Disposition, useful for programmatic CSV handling. It does not switch the body to JSON; raw=0 still suppresses that header.

Example request

$csv = FM_api('PurchaseOrders_exportLineItems', [
	'daysFrom'=>'-30','daysTo'=>'0','raw'=>'1',
]);

Example response

"Purchase Order ID","Purchase Order Number",Reference,Supplier,"Date Created","Date Approved","Date Sent","Delivery Date","Linked To","Link Type","Item Description",Quantity,"Total Net","Total Tax","Nominal Code","Order Status","Req Order ID"
1042,318,PO-318,"Example supplier","2026-11-05 09:00:00",,,,,,"Packing materials",2.5,25.00,5.00,EXP-LOCAL,Open,0

Response is raw text/csv, with attachment filename purchase_order_lineitems.csv unless raw is present.

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 value: daysFrom"}The required lower-bound key is absent.
{"error":"permission denied"}The required page permission is missing. Hidden/deleted records are omitted from collections; explicit parent readers reject an inaccessible parent.

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

Behaviour and edge cases

  • Filters active visible parents, then optional parent creation dates and search over supplier name/reference/header-ID substring. All received statuses, including Cancelled, remain unless excluded by other data. Rows sort by parent ID, line sort_num and line ID.
  • CSV columns are Purchase Order ID/Number, Reference, Supplier, Date Created/Approved/Sent, Delivery Date, Linked To, Link Type, Item Description, Quantity, line Total Net/Tax, Nominal Code, Order Status and Req Order ID. Unit cost, tax code, delivered quantity and line ID are not output columns.
  • Catalogue descriptions require active visible stock and stock View; missing descriptions become "unknown item". Miscellaneous descriptions use stock_text. Supplier and target display names require related View and visibility.
  • Line net/tax exclude carriage; export does not append or apportion a carriage row. Header-only orders produce no rows. No pagination/cap is present; no-match output is the CSV header.
  • Builds the CSV in a request-local php://temp stream; concurrent exports do not overwrite one another’s file. raw, where supported, changes only the attachment header.

Side effects

  • Reads visible order data, writes CSV into a request-local temporary stream, sends download headers and exits. No shared tenant filename, order, stock or financial mutation.

See it in Fieldmotion

CRM1

The CRM1 export buttons are hidden when userdata.permissions bit 256 is set; this endpoint does not enforce that export flag. In CRM1 Purchase Orders, choose Export Line Items; inspect the POST to PurchaseOrders_exportLineItems.

CRM2

No direct CRM2 literal caller was found in the searched client source. CRM2 uses PurchaseOrders_getExportLineItemsData.

Related endpoints