Job types
Set a job type’s default department
/a/JobType_setDepartment
Set the department offered as a default when a job editor selects this type.
When to use this endpoint
Use JobType_setDepartment for CRM1’s Job Types department cell. Use JobType_updateData for the CRM2 mapped editor.
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 | Yes | Existing positive job-type ID. |
department | Integer string | Yes | Department ID after integer conversion. 0 clears the default. Other IDs are stored without checking that a department exists or is active. |
Example request
$result = FM_api('JobType_setDepartment', [
'id' => '42',
'department' => '7',
]);
Example response
{
"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 is absent or integer-converts below one. |
{"error":"missing or invalid parameter: department"} | The department key is absent or null. |
{"error":"job type does not exist"} | No type matches the ID. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- An equal integer value is a no-op and leaves
last_editedunchanged. - CRM1 applies a nonzero type department when the type changes. CRM2 applies it only when the job’s department input is empty.
- Changing the default does not update existing jobs and does not reconcile the type’s default form.
Side effects
- On change, updates the department and timestamp and advances the job-type cache marker.
- This focused setter writes no generic field-level audit entry.
See it in Fieldmotion
CRM1
Open Settings → Job Types and change the Department cell. The options come from Departments_list, but the setter itself does not revalidate the chosen ID.
CRM2
CRM2’s Job Types module filters the default-form picker by department but saves the department through the mapped update route.
Related endpoints
JobType_setFormsets the associated default form.JobType_updateDataupdates mapped fielddepartment.