Job types
Update job-type mapped fields
/a/JobType_updateData
Update one or more job types through CRM2’s named field map and record field-level history.
When to use this endpoint
Use JobType_updateData for CRM2’s configurable Job Types edits, including its bulk archive actions. Focused JobType_set* routes preserve CRM1-specific validation and response behavior.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string or native array | Yes | Target ID or an already-decoded array of IDs. Scalar mode returns row-specific warnings. Array mode processes sequentially, discards every per-row result, and returns {"ok":1}. |
name | String | No | Complete replacement name. Blank, whitespace-only, duplicate, and arbitrarily long values are accepted. |
priority | Integer string | No | Default priority after integer conversion. The tenant priority choices are not checked. |
notes | String | No | Complete replacement notes. CRM2 submits encoded note-list text; valid note objects containing @username can create in-CRM mention notices. |
meta | String or JSON-compatible value | No | Complete metadata replacement. Named meta* values in the same request are merged later and take precedence for their keys. |
archived | Integer string | No | Archive value after integer conversion. CRM uses 0/1, but other integers are accepted. |
nominalCode | String | No | Complete nominal-code replacement without account or length validation. |
taxSettings | String or JSON-compatible value | No | Complete tax-settings replacement. Arrays/objects are JSON-encoded, strings are stored verbatim, and blank string becomes SQL null. |
department | Integer string | No | Default department after integer conversion. Existence is not checked. |
metaFormID | String | No | Replaces meta.form_id without verifying the form. |
metaSendNotification | String | No | Replaces meta.send_notification without restricting it to 0, 1, or 2. |
metaNotificationEmail | String | No | Replaces meta.notification_email without email validation. |
metaOrderNum | Integer string | No | Replaces meta.orderNum after integer conversion. Unlike creation, omission does not supply a default. |
lastEdited | Datetime string | No | Accepted by the map, but any changed update appends current server time after mapped values, so the supplied timestamp does not survive. |
noRecord | Native array | No | Mapped keys whose generic audit entries should be marked hidden. It does not suppress the writes or mention notices. |
Example request
$result = FM_api('JobType_updateData', [
'id' => '42',
'name' => 'Emergency repair',
'priority' => '4',
'metaFormID' => '18',
]);
Example response
{
"ok": 1
}
Scalar no-op input returns {"warning":"No Change."}; a missing row returns {"warning":"No data."}; only unknown update keys return {"warning":"no updated fields."}. Supplying only id returns {"ok":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: id"} | The id key is absent. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Unknown request keys are ignored. UI readonly flags are not API write protection, and the focused setters’ type/form/department/email/priority validation is not repeated.
- Named metadata fields preserve unrelated keys when existing/full metadata is valid JSON; otherwise the relevant metadata is rebuilt as an object.
- Every changed scalar row receives current
last_edited. A suppliedlastEditedcan appear in audit comparison even though current time is ultimately stored. - There is no filtering or pagination beyond explicit target IDs.
Side effects
- Changed rows advance the job-type cache marker and receive generic audit entries for each changed mapped field.
- Encoded notes are scanned for mentions after any non-error response. Matching usernames can receive an in-CRM notice linked to the Job Types page.
- Existing jobs and invoices are not rewritten when their type defaults change.
See it in Fieldmotion
CRM1
A production-source search found no direct CRM1 caller. CRM1 uses the focused setters on its Job Types table.
CRM2
Open Settings → Job Types and edit ordinary mapped fields or use bulk Archive/Unarchive. The shared module derives this endpoint from its API prefix.
Related endpoints
JobType_updateFieldreplaces one map key across explicit IDs without mention processing.JobType_getRequestedDetailsreads the same mapped keys.