Form definitions, recorded responses and exports
Export main Job Form answers as CSV
/a/Form_exportDataAsCSV
Download matching Jobs with main-form answers and identifying report columns.
When to use this endpoint
Use the Form Data report’s export without linked tables. Read the response as a CSV stream, not JSON, and use a CSV parser for quoted fields.
Authentication and permissions
Authenticate with a signed API key (acting as its owner) or a logged-in CRM session on the routed account host. Session calls include the dispatcher’s CSRF value when configured. IDs refer to the authenticated tenant unless an explicit cross-account copy is described.
Requires Report Form Data View (pageReportFormData_view) via the shared permission helper. Client administrators pass; a genuinely role-less legacy user retains that helper’s legacy allowance. Role/session grants are honored when present. The handler does not add a Job TeamAccess predicate.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer-compatible ID | Yes | Job Form ID. |
dateFrom, dateTo | Account-local date text | Yes | Scheduled epoch strictly after dateFrom midnight and through dateTo 23:59:59. |
search, customer | Text | Yes; may be blank | These keys must be present even when no text filter is wanted. |
user_id, job_id, department | Integer-compatible values | Yes; may be 0 | These keys must be present; zero disables the corresponding filter. |
parent_id | Positive integer-compatible ID | No | Ordinary Customer Jobs whose customer_id matches, or whose saved customer_details.parent_id matches. Excludes Asset Jobs. |
Example request
$csv = FM_api('Form_exportDataAsCSV', [
'id'=>'1042','dateFrom'=>'2026-11-01','dateTo'=>'2026-11-26',
'search'=>'','customer'=>'','user_id'=>'0','job_id'=>'0','department'=>'0',
]);
Example response
User,Worker,Customer/Asset,Date of Meeting,Contract,Status,Form Num,"Result",Job Ref,Postcode,Street Address1,Street Address2,Town,Region,Country,Parent,Job Duration,Job ID,Date Created,Job Finish,Job Type
Success is CSV bytes beginning with UTF-8 BOM; the example omits that invisible prefix. Pre-stream validation failures return an error object. Failures after streaming starts cannot be assumed to be a clean JSON response.
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: id"} | Missing/nonpositive Form ID. |
{"error":"missing parameter: search"} | Representative missing filter key; dateFrom/dateTo/customer/user_id/job_id/department have analogous errors. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Returns UTF-8 CSV with a byte-order mark, attachment filename form_data_export.csv and no JSON envelope. Header-only output is a valid empty export; the example shows a form with one Result field. Header labels are literal legacy export names.
- Column order: User, Worker, Customer/Asset, Date of Meeting, Contract, Status, Form Num; each current form field; then Job Ref, Postcode, Street Address1, Street Address2, Town, Region, Country, Parent, Job Duration, Job ID, Date Created, Job Finish, Job Type. Worker comes from user meta.worker_id; Parent is the Customer parent name or resolved Asset owner name.
- Exports all nondeleted matching Jobs, regardless of completion/status. Reads 100-Job offset batches ordered by scheduled epoch then ID. No caller start/length controls; concurrent changes can alter a live export. No explicit active/archived-form filter or comprehensive form existence check.
- search matches reference, assignee name, Customer name, Asset name/code and serialized form_values. customer matches Customer/Asset names. department matches Job department OR assignee department membership OR ordinary Customer department. All supplied filters combine with AND.
- Department answers become names; select/combobox values drop the colon suffix; multi-select arrays join with comma-space. Newlines in ordinary answers become literal \n. Images export blank/no image markers, not files; signatures use signature supplied. Calculation formats convert seconds/minutes or date/time values using legacy metadata.
- Scheduled dates use account-local conversion. Date Created is converted from UTC using timezone (default Europe/Dublin, explicitly blank UTC). Job Finish uses that conversion only for stored values after 2020-09-07 12:35; earlier values remain raw. Duration uses the complete start epoch and completion datetime, preserving overnight/multiday hours. Missing, malformed or negative elapsed values are blank.
- Customer/Asset enrichment is cached by type plus numeric ID, so overlapping IDs do not mix names or addresses. Status labels use positional configured Job Status names.
Side effects
- Database reads and streaming output only. No export checkpoint, Job status, answer or history is changed.
See it in Fieldmotion
CRM1
In Reports → Form Data, Export without tables builds a POST form containing every required filter key. Inspect Form_exportDataAsCSV rather than the grid’s Form_dataGetDT request.
CRM2
In Form Data, export with tables disabled posts to php/api.php with extra=/Form_exportDataAsCSV, CSRF and all required filter keys. Customer/Asset picker labels become the customer text filter.
Related endpoints
Form_exportDataAsCSVWithSubforms— include linked table answers, with a different row shape.Form_dataGetDT— page the legacy response grid.