Jobs: recurrence workflows and lists
Refresh cached next-job and last-completion dates for a recurring sequence and its maintenance records
/a/JobRecurrence_updateNext
Refresh cached next-job and last-completion dates for a recurring sequence and its maintenance records.
When to use this endpoint
Refresh cached next-job and last-completion dates for a recurring sequence and its maintenance records.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. All records resolve in the authenticated tenant. This handler has no additional Job edit-bit, department-visibility or owner check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
rid | Integer-like scalar | Yes | Positive recurrence ID, intval. HTTP callers cannot select another tenant by supplying pid/cid. |
Example request
$result = FM_api('JobRecurrence_updateNext', ['rid'=>'1042']);
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: rid"} | ID absent/nonpositive. |
{"error":"could not read recurrence jobs"} | Recurrence or derived-job query failed. |
{"error":"job recurrence does not exist"} | No matching recurrence. |
{"error":"Unable to save job delivery changes"} | Checked tenant transaction failed and was rolled back. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Normalizes positive cached job IDs in first-seen order, ignoring malformed/duplicate tokens without rewriting the saved CSV. Empty/separator-only caches clear derived state.
- Next job is the non-deleted, incomplete cached job with earliest meeting_time_e, breaking ties by ID. There is no future-time or recurrence-active requirement: overdue jobs remain eligible.
- Last completed job is the non-deleted cached job with nonzero completion state, latest date_completed, then lowest ID. This is not the latest scheduled job.
- Sets recurrence next_date to the selected next job’s tenant-local datetime or NULL. Updates every matching maintenance row: next_app_id/next_date from that job, last_date from the completed job or NULL.
- Internal worker calls can use the trusted global pid context without a CRM session; pid is not an HTTP tenant-routing parameter.
- Mobile clients were checked separately: recurrence notes/files are synchronized through m/www syncDownloads/syncDownloadOne and notes uploads, not direct calls to this endpoint. Those intermediary contracts are not expanded by this API route.
Side effects
- Checked tenant transaction locks the recurrence and atomically updates recurrence edit timestamp/operation marker and maintenance derived dates. No history entry is created.
- Does not change membership, delete jobs, regenerate children, bump worker priority or alter global expiry reminders.
See it in Fieldmotion
CRM1
No direct UI call found. Job status changes, deletion/membership lifecycle and some job saves invoke this internally. Observe the initiating Job_* request rather than expecting a separate updateNext request.
CRM2
No direct UI call found; the same backend lifecycle is used by CRM2 job changes.
Related endpoints
JobRecurrence_removeJobschanges cached membership, then refreshes dates.