# \_getExportData

This function prepares Job 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.

#### apptType

integer

#### client

text. all or part of the job customer/asset name

#### daysFrom

integer. used to indicate date range.

#### daysTo

integer. used to indicate date range.

#### department\_id

integer

#### form\_id

integer

#### form\_name

text

#### invoice\_sent

integer > 0 to return jobs where an invoice has been sent to the customer.

#### job\_ref

text

#### job\_type\_ids

array

#### lead\_account

integer

#### on\_app

integer. value of 1 to return only jobs that have synced to the user device.

#### overdue

text. value should be "overdue" to return jobs where is\_complete=0 and due\_date is prior to today.

#### parent\_id

integer. id of parent customer where job is for a customer (not an asset)

#### priority

integer.

#### report\_sent

integer > 0 to return jobs where a report has been sent to the customer.

#### status

integer. job status, aka is\_complete

#### user\_id

integer

### Accepted Fields

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

#### appId

integer. job id

#### attendees

text. email address(es) of job attendees

#### cdate

datetime of the job

#### cdate\_e

integer. datetime of the job in epoch time

#### contract\_id

integer

#### created\_by

integer. user id.

#### current\_user\_id

integer

#### customer\_id

integer

#### customer\_type

integer. customer type id

#### date\_completed

datetime of the job completion (predicted or actual)

#### date\_completed\_e

integer. dateime of job completion in epoch time

#### date\_started

datetime when job was first marked "in progress"

#### date\_started\_e

integer. epoch time.

#### ddate

integer. deletion date in epoch time.

#### deleted

integer. deletion status. value of 1 if job has been deleted

#### department\_id

integer

#### due\_date

date

#### due\_date\_e

integer. job due\_date in epoch time.

#### edited\_uuid

text

#### files

text

#### form\_id

integer. id of job form.

#### form\_num

integer

#### form\_type

integer. id of form type. default 0 for job forms.

#### form\_values

json

#### hours

float

#### hours\_cost

float

#### id

integer. job id.

#### is\_complete

integer. job status.

#### job\_ref

varchar

#### last\_edited

datetime

#### last\_edited\_e

integer.

#### location

text

#### meeting\_time

datetime of job

#### meeting\_time\_e

integer. job datetime in epoch time.

#### meeting\_time\_flexible

integer. value of 1 if job time is marked flexible.

#### meta

text

#### mileage

float

#### mileage\_cost

float

#### notes

text

#### on\_app

integer. indicates whether job has synced to user device

#### price

float

#### price\_net

decimal (13,4)

#### priority

integer. job priority id.

#### schedule\_of\_rates

text

#### stock\_cost

float

#### stock\_notes

text

#### stock\_used

text

#### subform\_values

text

#### type\_id

integer. job type id

#### user\_id

integer

#### user\_status

integer

#### user\_type

integer. value of 1 if job has been outsourced to another company

#### vehicle\_id

integer

### Example

```
FM_api('Appointments_getExportData', [
	'_ids' => ['131', '132', '133']
	'fields'=>['job_ref', 'cdate']
])
```

### Result

The results will include the job id and is\_complete status of each job, followed by the values for the fields requested, in the sequence requested.

#### On Success

```
[
	["id":"131", "is_complete":"1", "f0":"JB131", "f1":"2020-09-01 12:25:37"],
	["id":"132", "is_complete":"1", "f0":"JB132", "f1":"2020-09-02 13:20:27"],
	["id":"133", "is_complete":"0", "f0":"JB133", "f1":"2020-09-03 16:05:02"],
]
```
