Jobs: reports, email and links
Link a task to a job
/a/Job_taskLink
Create a task-to-job relation without moving or copying either object.
When to use this endpoint
Use from the task or job link picker after resolving both IDs. Link creation associates the existing records only; it is not task/job creation or cost transfer.
Authentication and permissions
Signed API-key authentication or a logged-in CRM session is required. The handler uses the authenticated tenant and has no additional role/page check.
The dispatcher also applies user/account and IP restrictions. CRM sessions carrying a CSRF token must supply X-FMCSRF or _csrf; missing or incorrect tokens can be rejected before the handler runs.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
job_id | Integer string | Yes | Positive physical job ID; existence is checked without a deleted filter. |
task_id | Integer string | Yes | Positive physical task ID; existence is checked without a deleted filter. |
Example request
$result = FM_api('Job_taskLink', [
'job_id' => '1042',
'task_id' => '703',
]);
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: job_id"} | Missing/nonpositive job ID; task_id has analogous guard. |
{"error":"task does not exist"} | No task row found. |
{"error":"job does not exist"} | No job row found. |
{"error":"this job is already linked to a task"} | The exact type-8 job/task pair exists; the wording does not mean a different task prevents linking. |
{"error":"Unable to save job delivery changes"} | A checked database write, audit or transaction failed; local transactional writes roll back. Cross-tenant files/commits are not distributed-atomic. |
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 duplicate check is scoped to this exact pair, not all tasks for a job. A job can link several tasks and a task can link several jobs.
- Both job and task must be active in the authenticated tenant. Common customer, assignment, task status and job completion are not required.
- Reads task metadata but does not use it. No pagination, filters, result ordering or limit apply to this one-pair mutation.
Side effects
- Inserts manymany type 8 (from_id=job, to_id=task) with Unix last_edited. Does not alter job/task fields, edit timestamps, history or mail.
See it in Fieldmotion
CRM1
Use Link to Task for selected jobs or link jobs from Tasks/task edit. jobsLinkToTask.js and pageTaskEdit/pageTasks post the pair; filter Job_taskLink.
CRM2
Use the Job-to-Task or Task-to-Job linking widgets, or the Tasks linked-jobs control. They post job_id/task_id to Job_taskLink and refresh the link list.
Related endpoints
Job_taskUnlinkremoves this pair and records its deletion for sync.Job_quoteLinkcreates a different relation and may also copy costs.