Digital Waste Tracking
Export waste receipt operations
/a/DigitalWasteTracking_operationsExport
Return up to 500 filtered operations rows as a base64-encoded CSV download.
When to use this endpoint
Use the same filter state as Operations. This is a JSON download response, not streamed CSV or a guarantee that all matching Jobs were exported.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session; session dispatch applies CSRF checks. The authenticated tenant must have features2.ukDigitalWasteManagement=1. The feature is read from the account record, not trusted from request input.
Requires Jobs View through Core_requirePermission('view', 'pageJobs').
Job reads and mutations enforce the authenticated tenant, active Job, TeamAccess department/assignment scope and the legacy department-based customer boundary. Collections filter before counts/pagination; explicit Job and cancellation requests check access before a service call or queue mutation.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
table_filters | Native object or JSON object text | No | Native filter object or valid JSON. Invalid/non-array input returns invalid table filters. It forces table start=0,length=500. |
job_id, from, to, status, profile_id | Plain Operations filters | No | Used in plain mode when table_filters is absent. Direct isTable requests are normalized to table mode. Export controls override caller paging and return at most 500 rows. |
Example request
$result = FM_api('DigitalWasteTracking_operationsExport', [
'table_filters'=>'{"status": "ready"}',
]);
Example response
{
"ok": 1,
"filename": "digital-waste-tracking-operations.csv",
"base64": "Sm9iLENvbXBsZXRlZCxGb3JtLFN0YXR1cyxQcm9maWxlLCJUcmFja2luZyBJRCIK",
"rows": 0,
"total": 0,
"truncated": false
}
The response example is a header-only export (rows=0). Nonempty exports append the filtered data rows.
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":"UK Digital Waste Tracking is not enabled for this account"} | The account feature is disabled. |
{"error":"permission denied"} | The required page action is absent; the shared permission helper retains its legacy roleless fallback. |
{"error":"invalid table filters"} | table_filters is invalid JSON or not an array/object. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Successful response has filename, base64 and rows (data-row count, excluding the header). Decode base64 as CSV. Columns are Job, Completed, Form, Status, Profile, Tracking ID. Job uses job_ref or falls back to the Job ID; Profile uses profile_name when present.
- Returns rows, total (matching filtered rows) and truncated=true when matches exceed the 500 exported data rows. Table mode exports data, including direct isTable calls; malformed table_filters is rejected rather than falling back silently.
- Table filters retain Operations search/sort and export the first 500 matching rows. Plain export reads at most five pages of 100 in descending Job ID order and stops on a short page. This cap does not limit the initial database scan.
- Both operational and PAT CSV exports prefix spreadsheet formula-like cells (=,+,-,@ after whitespace, or leading tab/newline) with an apostrophe. Ordinary values retain fputcsv serialization. Scope is applied before export/counts.
Side effects
- Builds a temporary in-memory CSV stream and returns its base64 content. No file is published and no receipt/provider mutation occurs.
See it in Fieldmotion
CRM1
No direct CRM1 caller was found in the production JavaScript source. The operator workflow is implemented in CRM2.
CRM2
Operations > Export passes table_filters=JSON.stringify(current widget filters), then downloads the returned base64/filename. It does not request a public export URL.
Related endpoints
DigitalWasteTracking_operations— Inspect filter counts and the table/plain contracts.DigitalWasteTracking_patExport— Export provider-test evidence instead of operational receipts.