Tasks
Export the legacy Tasks CSV
/a/Tasks_export
Stream CRM1’s legacy Tasks CSV using table-style visibility, date, field, and notes filters.
When to use this endpoint
Use Tasks_export for the CRM1 Tasks download. It streams CSV and terminates the request; FM_api() returns the CSV string, so do not JSON-decode it.
Authentication and permissions
The request must establish an authenticated tenant context with signed API credentials or a logged-in CRM session. This legacy handler uses the tenant database prefix without calling the normal login guard.
It performs no task, page, role, ownership, or privacy-permission check. Any visibility restriction described below comes from request filters or a specific server-side rule, not from a general Tasks permission check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
daysFilter | Integer string | No | Exact integer 1 enables created-date offsets. |
daysFrom / daysTo | Integer day offsets | No | Nonblank offsets relative to the current server timestamp. daysFrom is inclusive; daysTo + 1 is exclusive. Either bound can be used independently. |
viewEveryone | Integer string | No | Exact value 1 includes public tasks as well as tasks assigned to or created by the caller. Any other value limits to assigned/created tasks. |
view_private | Integer string | No | With viewEveryone=1, exact integer 1 removes the privacy/ownership filter. The handler does not authorize this flag. |
search | String | No | Substring across customer name, assigned-user name, due/created dates, subject, details, and resolution. |
taskID / createdBy / assignedTo / customerID / statusID / taskTypeID | Integer-compatible | No | Nonblank exact task, creator, assignee, customer, status, and type filters. |
subject / resolution / notes | String | No | Nonblank case-insensitive substring filters. Notes adds a note-table join; several matching notes can duplicate a task in the CSV. |
referenceDateField | Allowed field name | With relative date filter | One of assigned_date, cdate, due_date, id, or last_edited. It is used only when both offset parameters exist. |
dateFromFilter / dateToFilter | Integer day offsets | No | Inclusive day offsets from current server date, from 00:00:00 through 23:59:59. Both must be present. |
isDateUnix | Truthy value | No | Wraps the selected reference field in FROM_UNIXTIME. The task date columns are datetimes, so normal callers leave this unset. |
statusFilter | Comma-separated integers | No | Validated status IN filter. Invalid members return {"error":"invalid statusFilter"}. |
privacyFilter | Comma-separated integers | No | Applied only when the split list contains exactly one member. Multiple selections do not filter. |
Example request
$csv = FM_api('Tasks_export', [
'daysFilter' => '1',
'daysFrom' => '-30',
'daysTo' => '0',
'viewEveryone' => '1',
'view_private' => '0',
'statusFilter' => '0,1',
]);
file_put_contents('tasks.csv', $csv);
Example response
Id,"Date Created","Date Assigned","Assigned To",Customer,Subject,Type,"Due Date",Details,Resolution,"Public/Private",Status,"Minutes Spent",Notes
318,"2026-09-27 14:05:00","2026-09-27 14:05:00","Alex Smith","Northwind Service Centre","Confirm access details","Customer follow-up","2026-10-02 09:30:00","Confirm the site access details.",,1,Open,0,"Called customer"
The response is text/csv with attachment filename tasks.csv, not JSON. Rows are ordered by task ID.
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":"filesize too great for export - over 10000 rows of data found. Please narrow the date range and try again"} | More than 10,000 query rows are produced. Exactly 10,000 is allowed. |
{"error":"invalid referenceDateField: ..."} | A relative-date field is not in the five-name allowlist. |
{"error":"invalid statusFilter"} / {"error":"invalid privacyFilter"} | An applied comma-separated filter contains a non-integer member. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Status values are rendered as New, Open, Closed, or Archived. Privacy remains the stored numeric value.
- One plain-text note is accidentally exported as blank. One note containing the legacy JSON-array shape contributes each
contentvalue; multiple note rows are joined with|. - Customer, user, and task-type joins do not filter deleted/inactive related rows. A notes filter can produce duplicate task rows before the 10,000-row guard.
- The handler writes a fixed
tasks.csvtemporary file below the tenant’s temporary directory, streams it, and exits. Concurrent exports for the same tenant share that filename.
See it in Fieldmotion
CRM1
Open Tasks, apply the visible date/search/view controls, and choose Export. CRM1 posts those filters plus its CSRF token to Tasks_export.
CRM2
No direct CRM2 caller was found. CRM2 uses filtered IDs plus Tasks_getExportData.
Related endpoints
Tasks_getDTsupplies the related CRM1 table, but its filters are not identical.Tasks_getExportDatareturns selected export values as JSON for CRM2.