Invoices
Retrieve invoice layout details
/a/Invoice_getLayoutDetails
Load mapped invoice fields and assemble CRM2 invoice widgets for a configurable edit layout.
When to use this endpoint
Use this for CRM2 layout-backed invoice editing. Use Invoice_getRequestedDetails when widget assembly is not needed.
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 / ids | Integer / array | As a selector | Shared mapped-data selector for one or more active invoices. |
fields | Array | Yes | Mapped field names. Special values include widgetTableInvoice, widgetInvoiceRecurrence, widgetFormField, and the exact legacy mapped identifier appointmentId. |
Example request
$rows = FM_api('Invoice_getLayoutDetails', [
'id' => 981,
'fields' => ['id', 'num', 'widgetTableInvoice'],
]);
Example response
[
{
"id": 981,
"num": "INV-981",
"widgetTableInvoice": {"rows": []}
}
]
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: fields"} | No field array is supplied. |
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 result is always a row array, even for a single
id. Added dependency fields are removed before the response, and unknown mapped-field names are silently omitted. - Line items come from either storage format. Recurrence and custom-form widgets are assembled from related data. Nominal selections are normalized.
- For legacy invoices without
meta.oldDiscount, the response projects the stored absolute discount as a percentage. This read does not persist the projection or otherwise update the invoice.
See it in Fieldmotion
CRM1
No production CRM1 caller was found; CRM1 assembles invoice editing controls directly.
CRM2
Open an invoice edit dialog from Invoices. The layoutInvoiceUpdate display loads values through this mapped layout endpoint.
Related endpoints
Invoices_getDataTablesupplies paginated CRM2 invoice rows and IDs.Invoices_getDTis the CRM1 invoice-list counterpart.