Invoices
List jobs linked to an invoice
/a/Invoice_listLinkedJobs
Return direct or ancillary jobs linked to one invoice for invoice dialogs and email context.
When to use this endpoint
Use this to show invoice-to-job relationships or to choose job context for sending an invoice.
Authentication and permissions
The request must use a logged-in CRM session or valid signed API credentials and is scoped to that tenant.
Users whose legacy crm_access mask contains bit 64 receive {"error":"no permission to access api"}. No record-owner check is made.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer | Yes | Invoice ID. |
type | Integer | No | Defaults to 3 for direct links. Use 4 for ancillary links; other integers are accepted as legacy relation types. |
Example request
$links = FM_api('Invoice_listLinkedJobs', ['id' => 981, 'type' => 3]);
Example response
{
"ok": 2,
"jobs": [{"id": "2204", "job_ref": "JOB-2204", "is_complete": "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":"invoice does not exist"} | The invoice is absent or deleted. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- No links returns
{"ok":1,"jobs":[]}. A non-empty result usesok:2. - Only a direct-link request (
type=3) falls back to the invoice’s exact legacyappointment_idfield when no relation exists. Ancillary and other relation types do not use that fallback. - Soft-deleted jobs are omitted. Ordering is unspecified.
See it in Fieldmotion
CRM1
Invoice, Customer Invoice, Asset Invoice, and mail dialogs use this route to display linked jobs.
CRM2
Invoice linked-job dialogs, the invoice table widget, and Send Email load direct and ancillary relations with this route.
Related endpoints
Invoices_getDataTablesupplies paginated CRM2 invoice rows and IDs.Invoices_getDTis the CRM1 invoice-list counterpart.