When to use this endpoint

Use Opportunities_getDataTable for CRM2 table/Kanban data or unpaged export-ID discovery that must match CRM2 filters.

Authentication and permissions

This handler does not call Core_requireLogin or perform a page-permission check. The normal dispatcher and tenant-routing requirements still apply, but callers must not treat this route’s PHP function as an authorization boundary.

If a user session is present and is not a client administrator, the handler can apply department/account-manager customer restrictions described below.

Parameters

ParameterTypeRequiredDescription
fieldsNative arrayYesRequested opportunity map keys; unknown keys are ignored and id is always returned. Composite user/customer/quoteID fields return objects with id.
isTable / draw / start / length / limitInteger-compatibleNoTable mode defaults on with offset 0, length 10, and draw 0. Exact isTable=0 removes count/paging; positive limit then caps rows.
orderBy / orderDesc / orderShared mapped orderingNoExplicit named ordering or DataTables fallback. With no orderBy, this wrapper defaults to createDate ascending.
searchValue / searchFieldString / mapped name(s)NoCase-insensitive substring search over one/many mapped fields or All, including related customer/user/status/source names.
referenceDate / dateFrom / dateTo / offsets / time rangeShared mapped date controlsNoRelative tenant-calendar date/time filtering when referenceDate is a mapped date field.
Mapped filters / advanceSearch / groupByShared scalar/native-array controlsNoGeneric mapped filters, advanced conditions, and grouping.
customerNative picker object(s)NoCustomer filter values with id/type; opportunity customers use type 0.
childJobAndAssetNative arrayNoIf nonzero/present with customer, containing value 0 expands each type-0 customer filter to include its direct child customers. Despite the legacy name, no asset rows are involved.
metaCallbackStatusNative integer arrayNoOR-combined callback buckets: -2 before today, -1 yesterday, 0 today, 1 tomorrow, 2 after today. Dates use the PHP server calendar.

Example request

$table = FM_api('Opportunities_getDataTable', [
	'fields' => ['id', 'customer', 'user', 'value', 'status', 'metaCallback'],
	'start' => 0,
	'length' => 25,
	'draw' => 4,
	'orderBy' => 'createDate',
	'orderDesc' => 'desc',
]);

Example response

{
  "data": [
    {"id":"481","customer":{"id":"1042"},"user":{"id":"18"},"value":"2500","status":"1","metaCallback":"2026-10-01 09:00:00"}
  ],
  "draw": 4,
  "recordsTotal": "37",
  "recordsFiltered": "12"
}

Errors and unusual responses

ResponseCondition
{"error":"missing or invalid parameter: fields"}fields is absent.
{"error":"error in database query"}Generated selection/filter/order SQL fails.
Runtime type errorFields, composite filters, child expansion, callback buckets, grouping, or advanced controls have unsupported shapes.

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

Behaviour and edge cases

  • Soft-deleted opportunities are excluded. If an enabled row restriction resolves no customers, the result is forced empty.
  • Callback buckets operate on meta.callback strings. An array containing only unsupported bucket values builds an empty SQL group and can fail.
  • If no explicit orderBy is sent but a createDate filter parameter exists, its value is mistakenly tried as the order-field name before the shared fallback chooses a requested mapped field.
  • The handler itself does not check the tenant Opportunities feature switch. CRM2 hides the module unless that feature is enabled and uses client-side view/edit/delete/export permissions.

See it in Fieldmotion

CRM1

CRM1 uses the positional Opportunities_getDT route.

CRM2

The Opportunities table and Kanban view use this route. The export flow also calls it with fields=["id"] and isTable=0 to collect filtered IDs.

Related endpoints