Form definitions, recorded responses and exports
Clone named fields into another form
/a/Form_cloneFields
Append selected field definitions with fresh stable IDs to a target form.
When to use this endpoint
Use when reusing questions from an existing form without replacing the target’s fields. Choose field names from the source definition, then inspect both fields_cloned and errors.
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.
The handler adds no Forms page/role check. The dispatcher does not add a Form record-scope predicate; a screen’s CRM2 role controls are not evidence of an API restriction or a CRM1 permission requirement.
The account’s features2.disableFormEdits setting blocks this mutation with form edits are disabled for this account. A temporary user marked meta.is_tmp=1 bypasses that setting only.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
form_from | Positive integer-compatible ID | Yes | Source Form ID. |
form_to | Positive integer-compatible ID | Yes | Target Form ID. |
fields | Nonempty JSON array text | Yes | Exact source field names, in append order; not stable field IDs and not a native array. |
Example request
$result = FM_api('Form_cloneFields', [
'form_from'=>'1042','form_to'=>'1043',
'fields'=>json_encode(['Inspection result','Notes']),
]);
Example response
{"ok":1,"fields_cloned":2,"errors":[]}
Database numeric values can be JSON strings. Examples are representative; legacy application errors can use HTTP 200, so inspect the decoded 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: fields"} | Names missing, malformed, empty or not an array after decoding. |
{"error":"from form does not exist"} | Source missing. |
{"error":"to form does not exist"} | Target missing. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Source and target are not restricted by form type or archived state. Both must have valid, nonduplicate stable field IDs; missing legacy IDs are accepted.
- Names are matched exactly. Missing source names and names already in the target are skipped with per-field errors. A valid request can return ok with fields_cloned=0. Duplicate source names resolve to the final indexed definition.
- Each copied field receives a fresh JavaScript-safe ID. Local sources entries with form_id="field" are remapped when both referenced fields are selected; external/unselected references remain unchanged. Linked table IDs are retained: this does not copy those tables.
- Only definitions are copied; no existing Job answers or table rows are migrated. There is no pagination or server selection cap.
Side effects
- When at least one field is cloned: creates an Undo baseline, saves fields and last_edited with forms-cache invalidation, synchronizes linked-table form_parents metadata, logs cloneFields and creates an Undo snapshot. These steps are not one checked transaction.
See it in Fieldmotion
CRM1
In the Form editor, select fields and choose clone to another form. Filter Network for Form_cloneFields; names are JSON encoded.
CRM2
The clone-fields dialog can select several destination Forms. It sends one Form_cloneFields request per target and displays cloned counts and per-target errors.
Related endpoints
Form_copy— copy an entire form and optionally its linked tables.Form_updateData— read/edit the target definition through mapped fields.