Marketing
Query the CRM2 Lead Source table
/a/MarketingSources_getDataTable
Query lead-source rows through CRM2’s mapped table engine with selectable fields, search, filters, and paging.
When to use this endpoint
Use MarketingSources_getDataTable when reproducing CRM2’s Marketing Lead Source screen. For ordinary selector options, use MarketingSources_list.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
fields | Native array | Yes | Mapped fields from id, name, createDate, and lastEdited. Unknown names are skipped and id is always added. |
isTable | Integer string | No | Defaults to table mode. Exact integer 0 returns only data and allows optional limit. |
draw, start, length | Integer strings | No | Table counter, offset, and page size. Defaults are 0, 0, and 10. |
limit | Integer string | No | Positive non-table row limit; zero means no limit. |
orderBy / orderDesc | Mapped field / direction | No | Explicit sort. CRM callers use asc or desc. |
order[0][column] / order[0][dir] | Integer / string | No | DataTables ordering fallback with the shared leading-action-column offset. |
searchValue / searchField | String / field or native array | No | Case-insensitive substring search across one mapped field or All. |
name, createDate, lastEdited, id | Scalar or native array | No | Mapped filters. Name scalars use case-insensitive substring matching; numeric fields use equality; arrays use IN. |
referenceDate, dateFrom, dateTo | Mapped field and integer offsets | No | Shared relative-date filter in the tenant timezone; both offsets are needed. |
Example request
$table = FM_api('MarketingSources_getDataTable', [
'fields' => ['id', 'name', 'createDate'],
'draw' => '4',
'start' => '0',
'length' => '25',
'searchValue' => 'trade',
'orderBy' => 'name',
'orderDesc' => 'asc',
]);
Example response
{
"data": [{"id":"30124","name":"Trade show","createDate":"2026-10-01 15:05:00"}],
"draw": 4,
"recordsTotal": "12",
"recordsFiltered": "1"
}
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"missing or invalid parameter: fields"} | fields is absent. |
{"error":"error in database query"} | A generated mapped query fails. |
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 only data.
createDateandlastEditedare formatted from stored Unix timestamps.- The table has no active/deleted filter. Counts include every stored source.
- Unknown fields and malformed advanced-search items are silently ignored.
See it in Fieldmotion
CRM1
CRM1 uses MarketingSources_getDT.
CRM2
Open Marketing → Marketing Lead Source in CRM2 and filter browser developer tools for the exact function name. The shared display widget derives this route and sends its columns, filters, sorting, and pagination.
Related endpoints
MarketingSources_getDTsupplies CRM1’s positional table.MarketingSource_createDatacreates rows shown here.