When to use this endpoint

Use Departments_getDT only for the legacy seven-column table contract. Use Departments_getDataTable for mapped object rows.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.

The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.

Parameters

ParameterTypeRequiredDescription
lengthInteger stringYesSQL page size. There is no endpoint maximum; unsafe negative values can make the query fail.
startInteger stringNoZero-based offset; defaults to 0.
drawInteger stringNoDataTables sequence echoed as an integer; omitted input becomes 0 but can emit a runtime notice.
order[0][column]Integer stringNo0 orders by ID and 1 by name; all other values fall back to name.
order[0][dir]StringNoExact asc produces ascending order; every other/missing value produces descending order.
user_idInteger stringNoWhen nonzero, filters the raw users string with a substring LIKE match.

Example request

$page = FM_api('Departments_getDT', [
	'draw' => '4',
	'start' => '0',
	'length' => '25',
	'order' => [['column' => '1', 'dir' => 'asc']],
]);

Example response

{
  "draw": 4,
  "recordsTotal": "8",
  "recordsFiltered": "8",
  "data": [
    ["42", "North region", "18,24", "51,52", [{"po_id":"91","status":"0"}], ["3"], ""]
  ]
}

Errors and unusual responses

ResponseCondition
{"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: length"}length is absent. This validation occurs before authentication.
Runtime/database errorPaging values produce invalid SQL or nested order input has an unsupported 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

  • Each data row is positional: ID, name, raw users, raw assets, linked orders, decoded meta.customer_types, then an empty action cell.
  • For every page row, the handler separately loads all requisition and purchase orders whose target type is department (5); no status filter is applied.
  • Invalid/empty metadata produces an empty customer-type array. Counts remain database strings.

See it in Fieldmotion

CRM1

Open Users → Departments. The table sends DataTables paging/order values and its optional user filter to this route.

CRM2

CRM2 uses Departments_getDataTable, which returns keyed objects.

Related endpoints