# \_getExportData

This function prepares Invoice data for export.

There are two stages to the process. In the first stage, the required parameter \_ids is passed with a value of 1, along with optional parameters (see below) representing search constraints. This returns a list of IDs of matching items. In the second stage, the client machine retrieves data for items by sending the fields parameter to say what fields are needed, and an \_ids parameter to say which items to read. The client machine should make multiple requests such that the \_ids array contains at most 100 IDs at a time, to avoid timeouts or closed connections caused by too-high resource usage on the server.

### Required Parameters

#### \_ids (required)

Either 1 or an array of ids representing the jobs for which the export data will be retrieved.

#### fields(required)

Array. The names of the fields for which export data is required. (See list of accepted fields below).

Note: arrays should be JSON encoded.

### Optional Parameters

Used to apply constraints to the query.

#### customer

text. all or part of the invoice customer name.

#### from

integer. used to indicate date range.

#### to

integer. used to indicate date range.

#### inv\_no

text. invoice number.

#### search

text. all or part of the invoice id, invoice number, or invoice customer name.

#### status

integer. invoice status. -1 is draft, 0 is quoted, 1 is invoiced, 2 is paid, 3 is cancelled.

### Accepted Fields

The following values can be used in the `fields` array (required parameter):

#### account\_number

varchar(58). customer account number.

#### appointment\_id

integer

#### cdate

date. invoice creation date.

#### customer\_id

integer

#### customer\_type

integer. 0 for customer, 1 for asset.

#### discount

float. invoice discount.

#### discount\_vat

float. invoice tax discount.

#### doc\_no

varchar(32). invoice document number.

#### due\_date

integer. invoice due date in epoch time.

#### email\_sent

datetime. records when invoice was emailed to customer.

#### form\_id

integer. id of associated invoice form.

#### last\_edited

integer. records when invoice was last edited (in epoch time).

#### nominal\_code

integer

#### notes

text. invoice notes.

#### num

text. invoice number.

#### order\_no

varchar(32). invoice order number.

#### paid

float. amount paid against invoice.

#### pandp

float. postage & packing.

#### pandp\_vat

float. tax on postage & packing.

#### published

datetime

#### quote\_id

integer

#### status

integer. invoice status. -1 is draft, 0 is quoted, 1 is invoiced, 2 is paid, 3 is cancelled.

#### tax\_code\_id

integer. tax category id.

#### total

decimal(13,4). invoice total amount.

#### total\_vat

decimal(13,4). invoice total net.

#### total\_tax

float

#### type

integer. invoice type.

### Example

```
FM_api('Invoices_getExportData', [
	'_ids' => ['131', '132', '133']
	'fields'=>['num', 'nominal_code', 'total']
])
```

### Result

The results will include the invoice id and the customer\_type, followed by the values for the fields requested, in the sequence requested. Appended to the end of the array will be the customer\_type of the associated job.

#### On Success

```
[
	["id":"1", "invoice_customer_type":"0", "f0":"B1", "f1":"200", "f1":"100.0000", "job_customer_type":"0"],
	["id":"31", "invoice_customer_type":"0", "f0":"CT03", "f1":"200", "f1":"150.0000", "job_customer_type":"0"],
	["id":"100", "invoice_customer_type":"0", "f0":"FB210", "f1":"2101", "f2":"220.0000", "job_customer_Type":"0"],
]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fieldmotion.com/fieldmotion-api-docs/invoices/_getexportdata.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
