When to use this endpoint

First call with _ids=1, split the returned IDs into manageable batches, then send JSON-text _ids and fields. The export widget converts the fN aliases to spreadsheet columns.

These records represent work areas and map locations, not live user GPS positions or geofence definitions. Read IDs before editing; the stored user column is distinct from user-to-area membership.

Authentication and permissions

Authenticate using signed API-key fields or a logged-in CRM session. All object queries use the authenticated tenant. The handler has no additional page, role or feature check unless stated below.

Sign numeric request values as strings, including nested native arrays; only JSON-encode parameters that explicitly accept JSON text. See Getting started.

Parameters

ParameterTypeRequiredDescription
_ids"1" or JSON array textYesLiteral 1 returns {ids:[...]}; otherwise a nonempty JSON array of integer-converted IDs is required. Native arrays are not accepted by json_decode.
fieldsJSON array textFor data phaseNonempty array using id, name, lat, lng, last_edited, address, user_id, customer_type, customer_id, except changes is unsupported. Also accepts customer_id|customer_type. Colon-containing tokens are skipped.

Example request

$result = FM_api('Locations_getExportData', ['_ids'=>json_encode(['1042']), 'fields'=>json_encode(['name','customer_id|customer_type'])]);

Example response

[{"id":"1042","f0":"Depot","f1_0":"0","f1_1":"0"}]

Errors and unusual responses

ResponseCondition
{"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: _ids"}No _ids.
{"error":"_ids should be a JSON array of numbers"}Decoded ID list is empty or not an array.
{"error":"fields should be an array of requested field names"}Decoded fields empty or invalid.
{"error":"unknown field name: example"}A non-colon field is not in the export map.
{"error":"error in database query"}Data query failed; response also includes sql.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • ID discovery ignores field selection and returns all location IDs without sorting or filters. Data phase always returns id plus f0/f1/... aliases based on original field indexes.
  • Compound customer_id|customer_type produces fN_0 and fN_1. Duplicate field requests produce separate aliases; colon tokens leave gaps. Unknown non-colon fields return an error.
  • No CSV is streamed: responses are JSON. There is no pagination or ordering; caller chooses ID batch size. Deleted/missing IDs are omitted.
  • Only non-deleted work areas are read or changed. No department or ownership restriction is applied. CRM1/CRM2 hide Area Settings with feature bit 524288, but these APIs do not enforce that UI restriction.
  • The source search found no direct caller in the mobile JavaScript app or its m/www intermediary for this endpoint.

Side effects

  • Read-only; closes the PHP session write lock. No files, jobs or export-history records are created.

See it in Fieldmotion

CRM1

Area Settings → Export opens locations.csv through widgetExport, using Locations_getExportData in two phases. Export is hidden when permissions bit 256 is set, but the API does not enforce that bit.

CRM2

Area Settings → Export uses the same two-phase endpoint. The UI checks exportTableData/pageMain; that permission check is not performed by this handler.

Related endpoints