_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"],
]

Last updated