Files
Set one mapped file field
/a/File_setField
Set one mapped file field across one or more non-deleted file IDs and record a generic file audit event.
When to use this endpoint
Use File_setField for CRM2 inline switches and single-field edits. File_updateField is an equivalent wrapper around the same shared helper.
Authentication and permissions
Normal API transport requires signed API-key fields or a logged-in CRM session and a tenant context. Session CSRF applies except for the dispatcher’s upload/download exceptions.
These handlers do not add general Files Add/Edit/Delete or file-owner role checks. UI visibility is not that protection. Configured team-scope entry checks are separate and may validate the linked record and its Edit permission before a handler runs; see the route-specific note below. This does not introduce CRM2 role requirements for ordinary CRM1 requests.
When department/team or Assigned Jobs Only scope is configured for the actor, the dispatcher adds record-scope checks. This is selected by account features/actor flags, separately from the CRM2-only Files View check; the existing TeamAccess entry guard has no CRM-version condition. Explicit id/ids values are checked against visible file records. Other filename-only selections or mapped-filter-only bulk mutations can be rejected for lacking an explicit scoped selection.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
field | String | Yes | Mapped field name. Available names are id, filename, typeId, description, cDate, notes, ownerID, meta, name, typeEnum, lastEdited, url, customerReadable, fileLast_Edited, deleted, ddate, storageType, storageInstance, data, filesize, metaUserID, metaDateExpiry, metaTags, metaIncludeInEmail, metaEditNotesInPortal, metaShareWithSites, metaShowInPortal, metaOutsourcing, and metaLinkForm. |
val | Mixed | Yes | Replacement value converted according to the field map. Date values must be valid SQL dates. |
id / ids | Integer-compatible or native array | Yes | One file ID or multiple IDs. id takes precedence. Use the tenant file-record ID returned by upload/list/detail calls. This is separate from type_id/typeId (the linked resource ID), and from the random token in a storage URL. |
Example request
$result = FM_api('File_setField', [
'id' => '4821',
'field' => 'customerReadable',
'val' => '1',
]);
Example response
{
"ok": 1,
"oldData": [{"id": "4821", "customer_readable": "0"}]
}
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: field"} | Field is absent. |
{"error":"missing or invalid parameter: val"} | Value is absent. |
{"error":"missing or invalid field"} | Field is not mapped. |
{"error":"missing or invalid parameter: id/ids"} | Neither ID key is present. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Soft-deleted rows are excluded. Missing IDs or already-equal values return
{"ok":"1","warning":"no change required"}. - Changes set
last_edited, preserve JSON siblings for metadata fields, and write one genericfilesaudit log. They do not rebuild parent resource file lists or move storage when relationship/URL fields change. - No pagination applies to this write. Use a fresh metadata/list read before dependent work; an error after storage, audit or notification work does not imply that earlier steps were rolled back.
- val must be present and non-null. Blank text persists, numeric blanks become zero and blank date/JSON values clear. Native ID lists are integer-converted; encoded list strings are not decoded. A missing selection may produce a no-change acknowledgement instead of a not-found error.
- oldData uses storage-column names, with the old complete metadata column for nested aliases. JSON updates run per matching row; a later failure can leave prior rows changed. No mapped layout readonly flag creates a server-side allowlist of editable fields here.
See it in Fieldmotion
CRM1
No primary CRM1 caller was found; legacy pages use dedicated setters.
CRM2
Modern file option dialogs use this route for customerReadable and inline mapped fields.
Related endpoints
File_updateDatachanges several fields and sends mention notifications.- File identifiers and downloads explains file ID, resource ID, type enum, stored URL and the different content response shapes.