When to use this endpoint

Use ScheduleOfRates_getDataTable for CRM2’s configurable Schedule of Rates table or its unpaged export-ID discovery pass.

Authentication and permissions

This handler does not call the normal login guard or explicitly check for a tenant database prefix. Normal API dispatch must still establish tenant context; the PHP function itself must not be treated as an authorization boundary.

No page or role permission is checked. CRM2 hides actions and columns according to its client-side Schedule of Rates permissions.

Parameters

ParameterTypeRequiredDescription
fieldsNative arrayYesRequested mapped names from name, code, stockUsed, cost, lastEdited, description, meta, metaNominal, metaNominalID, metaNominalCode, metaTaxTypeID, assetTypes, labourUsed, priceBands, archived, and metaCustomerCosts. Unknown names are ignored and id is always included. taxType returns a composite object.
isTableInteger stringNoDefaults to table mode. Exact integer 0 returns only data and enables optional limit.
draw / start / lengthInteger stringsNoTable counter, offset, and page size; defaults are 0, 0, and 10. No endpoint maximum is applied.
limitInteger stringNoPositive non-table limit. Zero or a negative value leaves non-table output unlimited.
orderBy / orderDescMapped field / directionNoExplicit named ordering. Matching falls back case-insensitively, then to a requested field. Direction is inserted from this trusted CRM control without normalization.
order[0][column] / order[0][dir]DataTables valuesNoFallback ordering; the helper subtracts one for CRM2’s leading action column. Exact desc reverses the result.
searchValue / searchFieldString / mapped name(s)NoCase-insensitive substring search over selected or all mapped fields. Asset-type display search uses a scalar join that does not reliably represent the stored JSON-array field.
Mapped field filtersScalar or native arrayNoText/JSON scalars use case-insensitive substring matching; numeric scalars use equality; arrays use IN. Common filters are id, name, code, archived, and assetTypes.
advanceSearch / groupByNative arraysNoShared CRM2 condition objects and mapped grouping.

Example request

$page = FM_api('ScheduleOfRates_getDataTable', [
	'fields' => ['id', 'name', 'code', 'cost', 'archived'],
	'archived' => 0,
	'start' => 0,
	'length' => 25,
	'draw' => 7,
	'orderBy' => 'name',
	'orderDesc' => 'asc',
]);

Example response

{
  "data": [
    {"id":"430001","name":"Annual service","code":"AS-01","cost":"150","archived":"0"}
  ],
  "draw": 7,
  "recordsTotal": "24",
  "recordsFiltered": "18"
}

Errors and unusual responses

ResponseCondition
{"error":"missing or invalid parameter: fields"}fields is absent.
{"error":"error in database query"}The generated selection/filter/order query fails.
Runtime warning or type errorA list/composite parameter has an unsupported scalar shape.

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

Behaviour and edge cases

  • Archived rows are included unless filtered. The table has no deleted flag.
  • Table mode returns counts across all tenant rows and the filtered query. Non-table mode returns only data.
  • Stored JSON/text fields remain encoded; nested metadata map fields are extracted. taxType is composed from tax-type and nominal IDs.
  • Legacy advanced-search objects containing raw where expressions are trusted internal UI input and should not be constructed by third parties.

See it in Fieldmotion

CRM1

CRM1 uses ScheduleOfRates_getDT.

CRM2

Open Stock → Schedule of Rates. The shared table sends visible fields, filters, search, order, and paging here; export first calls non-table mode with fields=["id"].

Related endpoints