Job types
Set a job type’s default priority
/a/JobType_setPriority
Set the tenant-valid priority index offered as a default for jobs of this type.
When to use this endpoint
Use JobType_setPriority for CRM1’s Job Types priority cell. CRM2 normally saves mapped field priority through JobType_updateData.
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. |
priority | Integer string | Yes | Zero-based choice index after integer conversion. Negative and out-of-range indexes are rejected; blank or nonnumeric text becomes index 0. |
Example request
$result = FM_api('JobType_setPriority', [
'id' => '42',
'priority' => '4',
]);
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: priority"} | The priority key is absent or null. |
{"error":"job type does not exist"} | No type matches the ID. |
{"error":"invalid parameter: priority"} | The index is negative or has no configured label. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- The exact tenant setting
appointment-prioritiessupplies newline-separated labels when nonblank; index0is prepended as the blank choice. Without it, indexes0–5map to blank, None, Low, Normal, High, and Top. - An equal integer value is a no-op. CRM1 applies the priority whenever the type changes; CRM2 applies it only when the job priority is empty.
- Existing jobs keep their current priority.
Side effects
- On change, updates priority and
last_editedand 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 edit Priority. CRM1 builds the selector from the tenant choices and calls this route.
CRM2
CRM2’s Job Types module uses the mapped update route; that route does not repeat this tenant-choice validation.
Related endpoints
JobType_getPriorityreturns the stored scalar index.JobType_updateDatacan write an arbitrary integer priority.