Job types
Set a job type’s default duration
/a/JobType_setDuration
Store the default job duration as a number of hours in the type’s metadata.
When to use this endpoint
Use JobType_setDuration from either Job Types settings screen when changing the days/hours/minutes default.
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. |
val | Numeric value | Yes | Nonnegative duration in hours after PHP float conversion. Fractional values such as 2.5 are supported. A supplied nonnumeric string converts to 0 and is accepted. |
Example request
$result = FM_api('JobType_setDuration', [
'id' => '42',
'val' => '2.5',
]);
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 integer-converts below one. |
{"error":"missing or invalid parameter: val"} | The value is absent or float-converts below zero. |
{"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
- Invalid or non-object existing metadata is replaced with an object. Otherwise unrelated metadata keys are preserved.
- An equal numeric value is a no-op. Job editors copy the stored hours when the type is selected; existing jobs are not changed.
- The CRM screens use
work-day-startandwork-day-endonly to display part of the hours as days.
Side effects
- On change, writes
meta.duration, updateslast_edited, 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, select the Duration cell, and save days/hours/quarter-hours. CRM1 converts that UI value to hours and calls this route.
CRM2
Open Settings → Job Types and edit Duration. CRM2 uses the same focused endpoint.
Related endpoints
JobType_getDurationreturns the decoded stored hours.JobType_updateDatacan update other named metadata fields but has no dedicated duration map key.