Jobs: scheduling and lifecycle
Set one job's user and start together
/a/Job_setUserAndTime
Run the legacy time setter followed by tenant-user assignment for one active job.
When to use this endpoint
Apply one proposed time/tenant-user assignment. Both values are validated before saving; for several scheduler rows use Jobs_setUsersAndTimes.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. Legacy edit-restriction bit 128 is enforced; client administrators retain the existing admin exception.
The primary job selection is tenant-scoped. There is no automatic schedule-conflict or assignee-ownership check. Cross-tenant follow-ups use persisted outsourcing context.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Active job ID; missing/invalid/missing row gives job does not exist. |
job_time | Seconds or local datetime | Yes | Passed to the validated time setter. Missing/invalid input now stops before assignment. |
user_id | Integer string | No | Defaults to 0 (unassign). Positive IDs must be active tenant users; no user_type support. |
Example request
$result = FM_api('Job_setUserAndTime', [
'id' => '1042', 'job_time' => '1791885600', 'user_id' => '27',
]);
Example response
{"ok":1}
Returns ok after both setters succeed and preserves their warnings. An assignment error after a successful time save includes saved=1 and time_saved=1; the time is not rolled back.
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":"job does not exist"} | Initial lookup failed. |
{"error":"No permission to edit"} | Returned by the user setter. |
{"error":"Failed to update job assignment"} | Returned by the user setter after the time may already have changed. |
{"error":"missing or invalid parameter: value"} | Missing/invalid job_time; assignment is not attempted. |
{"error":"Invalid job assignee"} | User prevalidation failed; no time change is attempted. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Validates date and assignee before the first save, then runs time followed by assignment. A failed time step stops the operation.
- Each narrow setter reloads current state and request/global helper context is restored in finally. Assignment emails therefore see the newly saved start.
- Omitting user_id still means unassigned. There is no all-or-nothing transaction across external scheduling/email effects or schedule-overlap reservation.
Side effects
- Attempts all Job_setMeetingTime and Job_setUserId follow-ups in that order, including date and assignment emails, recurrence/reminders, costs and mobile-removal markers.
See it in Fieldmotion
CRM1
No direct production browser caller was found. CRM1 scheduler applies Jobs_setUsersAndTimes; ordinary timeline editing makes separate narrow requests.
CRM2
No direct production caller was found. The scheduler also uses Jobs_setUsersAndTimes.
Related endpoints
Job_setMeetingTimeruns dependent scheduling updates.Job_setUserIdsets a tenant-user assignee.Jobs_setUsersAndTimesapplies a scheduler batch and reports saved prefixes.