When to use this endpoint

Use MarketingExpenses_getDataTable for CRM2’s Marketing Expenses screen and its export ID-selection pass.

Authentication and permissions

This shared CRM2 table wrapper is intended for signed API-key requests or logged-in CRM sessions, so the request has an authenticated tenant database.

The wrapper omits the normal login guard and has no page or role-permission check. Without tenant context it can reach the wrong database prefix and return a database-query error instead of a structured authentication error.

Parameters

ParameterTypeRequiredDescription
fieldsNative arrayYesMapped fields from id, source, expense, expenseDate, createDate, and lastEdited. Unknown names are skipped and id is always added.
isTableInteger stringNoDefaults to table mode. Exact 0 returns only data and enables optional limit.
draw, start, lengthInteger stringsNoTable counter, offset, and page size; defaults are 0, 0, and 10.
limitInteger stringNoPositive non-table limit; zero means unlimited.
orderBy / orderDescMapped field / directionNoExplicit ordering. Sorting by source currently produces a database-query error because the shared sorter cannot use this map’s related-name search metadata.
order[0][column] / order[0][dir]Integer / stringNoDataTables ordering fallback. A column resolving to source has the same current sorting failure.
searchValue / searchFieldString / field or native arrayNoCase-insensitive substring search. Searching source resolves related marketing-source names through a join.
source, expense, expenseDate, createDate, lastEdited, idScalar or native arrayNoMapped filters. Numeric scalars are exact after conversion; date/text scalars use case-insensitive substring matching; arrays use IN.
referenceDate, dateFrom, dateToMapped field and integer offsetsNoTenant-timezone relative-date filtering. Use expenseDate or a mapped timestamp and supply both day offsets.
advanceSearch, groupByNative arraysNoShared CRM2 advanced conditions and mapped grouping controls.

Example request

$table = FM_api('MarketingExpenses_getDataTable', [
	'fields' => ['id', 'createDate', 'source', 'expense', 'expenseDate'],
	'draw' => '7',
	'start' => '0',
	'length' => '25',
	'referenceDate' => 'expenseDate',
	'dateFrom' => '-30',
	'dateTo' => '0',
	'orderBy' => 'expenseDate',
	'orderDesc' => 'desc',
]);

Example response

{
  "data": [{"id":"7124","createDate":"2026-10-01 15:20:00","source":"30124","expense":"425.5","expenseDate":"2026-10-01"}],
  "draw": 7,
  "recordsTotal": "40",
  "recordsFiltered": "1"
}

Errors and unusual responses

ResponseCondition
{"error":"missing or invalid parameter: fields"}fields is absent.
{"error":"error in database query"}A generated query fails, including current source-column ordering.

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

Behaviour and edge cases

  • Table mode returns data, integer draw, and scalar counts; non-table mode returns data only.
  • recordsTotal includes every expense row. There is no active/deleted filter.
  • createDate/lastEdited are formatted datetimes; expenseDate remains YYYY-MM-DD.
  • CRM2 export requests up to 100,000 IDs in table mode before submitting the comma-separated set to MarketingExpense_export.

See it in Fieldmotion

CRM1

CRM1 uses MarketingExpenses_getDT.

CRM2

Open Marketing → Marketing Expenses in CRM2 and filter browser developer tools for the exact function name. Table display, filters, sorting, paging, and export ID collection use this endpoint.

Related endpoints