Power BI
Export Power BI invoice data
/a/PowerBI_getInvoiceData
Export invoices and normalised invoice line items created within a date window.
When to use this endpoint
Use PowerBI_getInvoiceData for the legacy connector’s invoice and invoice-line tables. The aggregate feed can project either response key.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session so that the tenant database and user context are available. The handler performs no page or role-permission check.
This direct dataset route does not consume the unsigned api_id/api_key pair used by the Power BI connector. Use PowerBI_getData for the self-authenticating connector feed.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
from | String | Yes | An exact lower-bound fragment such as >="2026-09-01". It is not a plain date. |
to | String | Yes | An exact upper-bound fragment such as <="2026-09-30 23:59:59". It is not a plain date. |
dataset | String | No | Accepted by the aggregate feed but ignored by this helper: a direct call always calculates both datasets and cids. |
Example request
FM_api('PowerBI_getInvoiceData', [
'from' => '>="2026-09-01"',
'to' => '<="2026-09-30 23:59:59"',
]);
Example response
{
"invoice_data": [{"job_link":"Direct","job_id":"301","job_ref":"J-301","invoice_id":"88","invoice_customer_id":"1042","invoice_customer":"Example Ltd","invoice_date":"2026-09-03","num":"INV-88","status":"Invoiced","total":"120.00","paid":"20.00","owing":100,"total_net":"100.00","total_tax":20}],
"invoice_lineitem_data": [{"invoice_id":"88","item_code":"LAB","description":"Labour","price":"100","quantity":"1","net_price":"100","nominal_code":"4000","tax_percent":"20","tax_type":"T1","gross_price":"120","source":"labour","source_id":""}],
"cids": ["1042"]
}
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: from"} | from is absent. |
{"error":"missing or invalid parameter: to"} | to is absent. |
{"error":"invalid parameter: from"} / {"error":"invalid parameter: to"} | A bound has the wrong exact shape. |
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 inclusive bounds apply to invoice creation time. Soft-deleted invoices are excluded and results are ordered newest first; there is no pagination.
- An invoice with no job link is emitted once with
-placeholders. Each direct or ancillary link produces a separate invoice row withjob_link, job ID, and active job reference, so one invoice can appear more than once. - Customer and asset names resolve only against nondeleted records.
owingis recalculated as total minus paid, andtotal_taxas total minus total net. Status codes map to Draft, Quoted, Invoiced, Paid, or Cancelled. - Notes over 500 bytes become
--NOTES TOO LARGE FOR EXPORT--. Stored row/meta payloads are removed from invoice rows. - Line items are loaded through the current invoice row normaliser. Their output values are strings and contain invoice ID, item code, description, unit price, quantity, net, nominal/tax data, gross, source, and source ID. Invoices without lines add no line rows.
cidsis the de-duplicated list accumulated from exported invoice customer IDs and can contain null for asset/missing-customer invoices.
See it in Fieldmotion
CRM1
The legacy connector exposes invoice_data and invoice_lineitem_data as separate tables.
CRM2
CRM2 does not call this route for invoice screens.
Related endpoints
PowerBI_getDatais the supported aggregate connector feed and supplies tenant settings to this helper.PowerBI_authenticateestablishes the unsigned connector session used by the aggregate feed.