Suppliers
Query the CRM2 Suppliers table
/a/Suppliers_getDataTable
Query suppliers through CRM2’s mapped table engine with selectable fields, filters, search, sorting, and paging.
When to use this endpoint
Use Suppliers_getDataTable when reproducing CRM2’s Suppliers page or its filtered export selection. It exposes shared layout and data-table conventions.
For a smaller external contract prefer Suppliers_list or Suppliers_getById.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler calls the normal login guard but performs no additional Suppliers-page, stock, purchasing, role, create, edit, or delete permission check.
All records are selected from the authenticated tenant. CRM1 and CRM2 hide some controls through client-side permissions, but these endpoints do not repeat those UI checks.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fields | Native array | Yes | Mapped response field names. Available names are name, contactName, streetAddress1, streetAddress2, town, county, country, postcode, email, phone, notes, website, taxId, terms, accountNumber, refNumber, isActive, onHold, type, meta, createDate, lastEdited, editedUuid, accountsContact, accountsEmail, additionalEmail, and customValues. Unknown names are skipped and id is always added. |
isTable | Integer string | No | Defaults to table mode. Exact integer 0 returns only {"data":[...]} and enables optional limit. |
draw, start, length | Integer string | No | Table counter, zero-based offset, and page size. Defaults are 0, 0, and 10. Zero or negative page sizes are not rejected before SQL. |
limit | Integer string | No | Positive limit in non-table mode. Zero means no limit. |
orderBy / orderDesc | Mapped field / direction string | No | Explicit mapped sort. CRM sends asc or desc; the direction text is not separately allowlisted by this layer. |
order[0][column] / order[0][dir] | Integer / string | No | DataTables ordering fallback. The column is adjusted for the leading action column; exact desc selects descending. |
searchValue | String | No | Case-insensitive substring search across searchField or all mapped searchable fields. |
searchField | Mapped field or native array | No | Field(s) used by searchValue; omission searches All. |
advanceSearch | Native array | No | Shared CRM2 condition objects using a mapped field, condition, value, and optional AND/OR choice. |
referenceDate, dateFrom, dateTo | Mapped field and integer day offsets | No | Shared relative-date filtering in the tenant timezone. Both offsets are needed for the date range. |
groupBy | Native array | No | Mapped fields to add to SQL grouping. Unknown names are ignored. |
Mapped field filters | Scalar or native array | No | Any mapped field can filter. Text scalars use case-insensitive substring matching; numeric scalars use equality; arrays use IN. |
Example request
$table = FM_api('Suppliers_getDataTable', [
'fields' => ['id', 'name', 'accountNumber', 'email', 'onHold'],
'draw' => '4',
'start' => '0',
'length' => '25',
'searchField' => 'All',
'searchValue' => 'northshore',
'orderBy' => 'name',
'orderDesc' => 'asc',
]);
Example response
{
"data": [{"id":"488104","name":"Northshore Components","accountNumber":"NS-42","email":"orders@example.test","onHold":"0"}],
"draw": 4,
"recordsTotal": "42",
"recordsFiltered": "1"
}
Errors and unusual responses
| Response | Condition |
|---|---|
{"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"} | fields is absent. |
{"error":"error in database query"} | A generated mapped/filter query fails. |
Empty or broader-than-expected data | Unknown requested fields or malformed advanced-search items are silently ignored. |
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 suppliers are always excluded. Inactive and on-hold suppliers remain unless explicitly filtered.
- Table mode returns
data, integerdraw, and scalar counts. Non-table mode returns onlydata. recordsTotalcounts all non-deleted suppliers;recordsFilteredapplies mapped, search, advanced, and date filters.- Mapped accounting fields are read from metadata JSON.
customValuesis decoded through the field map rather than returned as the raw stored string. - The endpoint has no Supplier-page permission check beyond authentication.
See it in Fieldmotion
CRM1
No CRM1 production caller was found. CRM1 uses Suppliers_getDT.
CRM2
Open Stock → Suppliers in CRM2 and filter browser developer tools for the exact function name. The shared display widget sends selected layout columns, search, filters, sorting, and paging to Suppliers_getDataTable.
Related endpoints
Suppliers_getDTsupplies CRM1’s positional table.Suppliers_getExportDatareturns selected export fields.