When to use this endpoint

Use the CRM2 Purchase Orders table and its export ID-selection stage. This is a mapped camelCase contract, distinct from the positional getDT response.

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
fieldsNative array of mapped namesYesNative list, not a JSON-encoded string. id is always selected; unknown names and client-only calculations are omitted. Picker objects are rebuilt from backing fields; backing fields not explicitly requested can be removed from each response row.
start / length / drawInteger-compatible stringsNoTable mode defaults start=0, length=10, draw=0. start is a row offset; draw is echoed as integer. Negative or malformed paging values are rejected; no maximum page size is imposed.
isTable / limitInteger-compatible flagsNoDefault table mode. isTable=0 removes table paging/counts; only a positive limit then caps rows, while limit=0 means unlimited. start/length do not limit unpaged exports.
orderBy / orderDescMapped field / directionNoProvide both for named sorting in table mode; use asc or desc. Without them, order[0].column selects a field position after subtracting 1 (clamped at 0); exact order[0].dir=desc descends. No ID tie-breaker is added.
searchValue / searchFieldText / native field list or nameNoNonblank searchValue searches mapped fields and configured related display names. Default searchField is All. SQL LIKE wildcards retain their meaning.
Mapped field filtersScalars, native arrays or pickersNoFilters combine with AND. Text scalars use case-insensitive substring matching unless the map declares exact matching; lists use IN. Numeric scalars integer-convert, including decimal fields; list values follow numeric type conversion. Pickers match their ID/type components.
referenceDate / dateFrom / dateToMapped date field / relative day offsetsNoA valid referenceDate activates date filtering when both day offsets are supplied. Ranges include start-day midnight through end-day 23:59:59; the account timezone chooses today (fallback UTC). Unpaged results sort by the reference field ascending.
offsetFrom / offsetToNative {hour,minute} objectsNoAdditional date-time boundary offsets: hour is negated, minute is added. Not applied to date-only fields. These are legacy client controls, not general timezone identifiers.
timeRangeFrom / timeRangeToInteger hoursNoWith a valid referenceDate, timeRangeFrom activates an inclusive hour filter; omitted upper hour defaults 23 and reversed bounds swap. timeRangeTo alone does not activate it. Hour conversion uses the account timezone, fallback Europe/London.
groupBy / advanceSearchNative arraysLegacy controlsMapped grouping and advanced-search rules feed the shared SQL helper. Grouping does not make the count queries grouped counts. Use structured mapped conditions; do not submit raw SQL controls.
customerIDFilterNative IDs, JSON ID list or comma-separated IDsNoNormalized positive customer IDs. Matches direct Customer links, Quote customers and Jobs with customer_type=0. Empty/invalid-normalized lists add no customer predicate.
childJobAndAssetNative arrayNoWith a native customerIDFilter list, a 0 element adds immediate child Customers. Other elements add nothing here; this control does not traverse Assets or recursive descendants. A legacy customer-picker branch is not a mapped header filter.
sendEmailNative listNoOne element: 0 means date_sent IS NOT NULL (sent), 1 means IS NULL (not sent). A two-element list disables the filter; blank date strings count as sent because the predicate tests NULL only.
hasFilesNative listNoOne element: 0 requires any files row with type_enum=21/type_id=header ID; 1 requires none. Two elements disable it. Deleted files do not contribute. Private-file handling is unchanged.
returnedStatusScalar or native listNoEmpty, cleared, [] and null-like values disable selection. Any remaining nonempty scalar selects orders with active Goods Returned headers. This selection runs in SQL before pagination and counts; it is not a two-way boolean control.

Example request

$result = FM_api('PurchaseOrders_getDataTable', [
	'fields'=>['id','poNum','reference','targetType','targetID','orderNet','orderTax'],
	'start'=>'0','length'=>'10','draw'=>'1',
	'orderBy'=>'poNum','orderDesc'=>'asc',
	'sendEmail'=>['1'],
]);

Example response

{
  "data": [
    {
      "id": "1042",
      "poNum": "318",
      "reference": "PO-318",
      "targetType": "0",
      "targetID": "0",
      "orderNet": 25,
      "orderTax": 5,
      "customerID": "",
      "customerName": "",
      "returnedStatus": 0,
      "returnedData": []
    }
  ],
  "draw": 1,
  "recordsTotal": "12",
  "recordsFiltered": "1"
}

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: fields"}No native field list was supplied.
{"error": "error in database query"}Shared SELECT failed.
{"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

  • 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. The legacy Department Based Filter follows direct Customer links, Quote customers and ordinary customer-Job links; restricted users cannot discover unlinked or other unsupported targets. Configured TeamAccess uses the same boundary as the singular header readers.
  • Header fields use PurchaseOrder’s map: poNum/reference/status, supplier/target pickers and IDs, delivery/contact/date fields, approval/sent timestamps, customValues, invoiceReceived and meta paths. id is always returned. orderNet/orderTax are converted to line-only numeric totals by subtracting carriage from raw persisted amounts.
  • When targetType is projected, adds customerID/customerName and returnedStatus/returnedData. Customer data follows direct Customer, Quote or ordinary customer-Job links. Return data groups active Goods Returned headers linked through Goods Received; it is a presence flag, not a net returned quantity.
  • Project targetType and targetID for customer enrichment. Returned-status selection is a SQL predicate and works even when these fields are not projected.
  • recordsTotal counts active visible headers before search filters. recordsFiltered counts all matching SQL rows before paging, including the returned-order predicate. Returned filtering cannot turn an earlier page into an artificially empty page.
  • Related customer/Quote/Job and receipt display lookups apply their corresponding View and record boundary. hasFiles only considers nondeleted files.
  • Native field, grouping, sort and structured advanced-search controls are checked; raw where expressions and malformed values are rejected before SQL. Pagination values are nonnegative integers; no maximum size is imposed.

Side effects

  • Reads tenant data without modifying orders, lines, stock, approval, history or notifications.

See it in Fieldmotion

CRM1

No direct CRM1 literal caller was found in the searched client source. CRM1 uses PurchaseOrders_getDT.

CRM2

In CRM2 Purchase Orders, load/search/filter the table and inspect PurchaseOrders_getDataTable. The page is hidden without employer feature bit 262144; this handler does not enforce that feature flag. Export first calls it with fields=[id], isTable=0,limit=0 to obtain the complete filtered header-ID list.

Related endpoints