Jobs: recurrence settings
Prune stale cached recurrence job IDs
/a/JobRecurrence_checkJobIds
Remove missing or soft-deleted job references from an existing sequence's cached ID list.
When to use this endpoint
Use when the recurring-jobs table needs to repair a stale child cache. Despite its name, this is a potentially mutating repair, not a pure validation call.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. Tenant context is required. The Job edit-restriction bit 128 applies, with the existing client-administrator exception.
IDs resolve inside the authenticated tenant. There is no additional department-visibility or recurrence-ownership filter.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Recurrence ID, converted to an integer. It is not a job ID. |
Example request
$result = FM_api('JobRecurrence_checkJobIds', ['id'=>'1042']);
Example response
{"ok":1,"msg":"ids corrected"}
Returns {"ok":1,"msg":"ids corrected"} only after a changed repair commits. An already-canonical cache returns {"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"} | Missing/nonpositive recurrence ID. |
{"error":"that recurrence does not exist"} | No sequence row. |
{"error":"could not read recurrence jobs"} | Failed active-job query. |
{"error":"No permission to edit"} | Job edit restriction without client-admin exception. |
{"error":"Unable to save job delivery changes"} | The checked repair/history transaction failed and 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 the cached comma-separated text to unique positive integer IDs in first-seen order, then removes missing/deleted jobs while preserving that order.
- Rewrites only when the canonical pruned CSV differs from saved text; malformed/duplicate tokens are repaired even if active-job counts happen to match. An all-invalid cache becomes an empty string.
- The first remaining valid cached job stays first. No database-result-order reordering occurs; completed active jobs remain eligible.
- Does not add children from meetings.recurrence_id, deactivate an empty sequence, rebuild jobs or refresh next_date. No pagination or child department/user filter applies.
Side effects
- Locks the recurrence; changed ids, last_edited/edited_uuid and checked history commit together. Read/write/history failures roll back the repair. A no-op does not touch edit metadata.
See it in Fieldmotion
CRM1
Open the child-jobs dialog from Jobs → Recurring Jobs or a customer recurring-jobs tab. On close/refresh the table invokes JobRecurrence_checkJobIds before redrawing.
CRM2
No direct production CRM2 caller was found. The module reads cached IDs and uses getNextJob for a missing date fallback.
Related endpoints
JobRecurrence_getreloads the corrected cache.JobRecurrence_getRIDdepends on that cache for membership lookup.