When to use this endpoint

Use Department_updateData for CRM2’s shared Departments editor. It supports scalar or bulk IDs, but reciprocal user processing is reliable only for a single department ID.

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
idInteger string or native arrayYesTarget department ID or native list of IDs. JSON array text is not decoded. Bulk mode discards per-row warnings/errors.
name / users / assets / customersString or native arrayNoComplete replacements for the mapped text columns. Native arrays are JSON-encoded. Only users receives reciprocal synchronization.
metaJSON value or JSON textNoComplete metadata replacement. Nonblank string input is not JSON-validated.
metaCustomerTypesValue or native arrayNoReplacement for meta.customer_types, preserving other decodable metadata keys.
cdate / lastEditedDatetime stringsNoMapped timestamps. Blank becomes SQL null; any successful field change automatically sets last_edited to the current server datetime.
noRecordNative arrayNoInternal audit control listing mapped keys whose generic history entries should be hidden.

Example request

$result = FM_api('Department_updateData', [
	'id' => '42',
	'name' => 'Northern region',
	'users' => ['18', '24'],
]);

Example response

{
  "ok": 1
}

A scalar no-op returns {"warning":"No Change."}; a missing row returns {"warning":"No data."}; supplying only unknown update keys returns {"warning":"no updated fields."}.

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: id"}id is absent and users is not being processed.
{"error":"department does not exist"}users is present and the scalar ID does not resolve to a department.

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

Behaviour and edge cases

  • User lists accept JSON text, comma-separated text, or a native array for membership comparison. Blank/invalid IDs and duplicates are removed for reciprocal processing, though the department stores the mapped input form.
  • Added/removed existing users receive a JSON-encoded departments list. Missing users are silently ignored and can remain in the department value.
  • Unknown keys are ignored. Scalar ID zero normally returns No data.; there is no explicit positive-ID or page-permission check.

Side effects

  • Updates the department, advances last_edited, invalidates the departments cache, and writes generic field-level audit history.
  • For changed users, updates reciprocal tenant user departments JSON and invalidates the users cache, but does not advance those users’ last_edited. The operations are not transactional.

See it in Fieldmotion

CRM1

CRM1 uses focused setters for department editing rather than this route.

CRM2

Open Users → Departments. The shared display widget uses this route for names, assets, customer-type metadata, and other mapped edits.

Related endpoints