Quotes: queries, documents and delivery
Export legacy quote cost lines
/a/Quotes_getLineItemExportData
Expand stored quote cost rows for the CRM1 line-item exporter without recalculating every section.
When to use this endpoint
Use to reproduce the legacy CRM1 export. The plural LineItems endpoint uses different calculation and deletion behavior.
Authentication and permissions
Authenticate with signed API-key fields or a CRM session. Requires Quotes View (pageQuotes_view); non-admin users blocked by legacy crm_access bit 32 are denied. Client administrators inherit page permissions.
Quote visibility follows the account’s department/account-manager customer filters for non-admin users, including signed keys. Export routes additionally require pageMain_exportTableData. Linked Jobs require Jobs View and their TeamAccess scope; invoice enrichment requires Invoices View and the legacy invoice access check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
_ids | String: 1 or JSON-encoded ID array | Yes | Literal 1 starts selection and returns integer IDs. Otherwise submit a nonempty encoded ID array to fetch rows; entries integer-convert. An empty list fails. No server checkpoint is stored. |
fields | JSON-encoded ordered array of field names | Fetch phase | Requested positions become f0, f1, etc. Unknown names fail. Native fields arrays are not JSON-decoded by these exporters. |
from / to | Date strings | No; selection only | Independent inclusive cdate bounds; to appends 23:59:59. No calendar validation. |
quote_id / quote_num | String patterns | No; selection only | Contains-style ID/reference LIKE matches, not exact quote_id equality. Wildcards retain SQL LIKE meaning. |
form_id / contract_id / user_id | Integer-compatible IDs | No; selection only | Truthy exact filters after conversion. |
customer / notes / search | String patterns | No; selection only | Customer/name, quote notes, and global ID/reference/customer search respectively; individual exporter differences are described below. |
status | Integer-compatible value or 999 | No; selection only | Omitted/blank or 999 means all statuses. Otherwise filters by integer status; no enum allowlist. |
Example request
$rows = FM_api('Quotes_getLineItemExportData', [
'_ids'=>json_encode(['1042']),
'fields'=>json_encode(['quote_num','quote_costs']),
]);
Example response
[{"quote_id":"1042","f0":"QT-1042","f1":"{\"description\":\"Call-out\",\"qty\":2,\"cost\":5,\"price\":10,\"summary\":\"Other\",\"amt\":2,\"gross\":10,\"cost_total\":10,\"price_total\":20,\"gross_total\":20}","lineitem":"{\"description\":\"Call-out\",\"qty\":2,\"cost\":5,\"price\":10,\"summary\":\"Other\",\"amt\":2,\"gross\":10,\"cost_total\":10,\"price_total\":20,\"gross_total\":20}"}]
The lineitem sample is illustrative stored row content; optional source keys and their ordering depend on saved metadata. Decode f1/lineitem once to obtain the object.
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: _ids"} | _ids omitted/null. |
{"error":"_ids should be a JSON array of numbers"} | Fetch selector is empty, invalid JSON or not an array. |
{"error":"fields should be an array of requested field names"} | Missing/empty/invalid encoded fields. |
{"error":"permission denied"} | Required Quotes/Export permission is absent or legacy access restrictions apply. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Uses the same checked row exporter as Quotes_getLineItemsExportData, preserving the two-phase _ids contract, fN positions and encoded lineitem/quote_costs values. Both phases exclude deleted/invisible quotes and require Export.
- Rows come from Stock, SoR, Verbose, Other and Labour sections. Section totals supplied by clients do not override row inputs. Quantity aliases, Tax categories, fractional rates, row/header discount or markup and numeric storage bounds use the authoritative Quote pricing engine.
- price is the base unit selling price. price_total is adjusted net; gross_total includes adjusted Tax; cost_total is quantity times cost. Unit gross divides the adjusted row gross by quantity, returning zero for zero quantity instead of dividing by zero.
- Other preserves qty/amt fallback, Verbose uses net_price/amount and Labour uses priceph before calculation. Current item names are added; absent metadata/cost rows produce no export rows. Malformed cost data returns an error rather than an inconsistent unexpanded row.
- A read-only calculation verifies inputs and returns totals without modifying stored costs, summaries or quote timestamps.
- No direct caller for this endpoint was found in the mobile app or its m-service intermediary.
Side effects
- Reads active permitted records without quote cost, history, email or derived Job-cache writes.
See it in Fieldmotion
CRM1
Quotes → Export Line Items uses Quotes_getLineItemExportData through the legacy export widget.
CRM2
No direct caller found; CRM2 uses the plural Quotes_getLineItemsExportData.
Related endpoints
Quotes_getLineItemsExportDatarecomputes several row totals for CRM2.Quotes_getExportDataexports one quote header row.