Form definitions, recorded responses and exports
Preview and merge duplicate Job Tables
/a/Form_mergeTables
Consolidate compatible Job Table definitions and saved answers using a revision-confirmed transaction.
When to use this endpoint
Use the CRM2 Forms merge workflow for duplicate type-3 tables. Preview first, inspect counts, then submit the returned revision with explicit confirmation. Ordinary link replacement does not migrate saved answers.
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.
Requires Forms Edit (pageForms_edit) through the shared settings guard. Client administrators pass; other actors need the stored/session grant. This guard uses no legacy role-less allowance and is not conditional on the CRM version. The temporary-user edit-lock exception does not bypass it.
Also requires Jobs Edit (pageJobs_edit) with no legacy role-less allowance. The existing legacy edit restriction bit 128 rejects non-client-admin actors. Candidate Jobs must pass TeamAccess record authorization.
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 |
|---|---|---|---|
ids | Native list or JSON list text | Yes | 2–20 positive table Form IDs; duplicate IDs are removed and the list sorted. All must be active type-3 Job Tables. |
destination | Positive integer ID | Yes | Selected table to retain; must occur in ids. |
apply | 0 or 1 | No | Only integer 1/string "1" applies changes. Default preview. |
revision | SHA-256 text | On apply | Exact revision from the immediately preceding preview. Changes to the compared forms, Jobs or workflows invalidate it. |
confirmation | Exact text I am sure | On apply | Required explicit confirmation; case and spacing matter. |
Example request
$preview = FM_api('Form_mergeTables', [
'ids'=>json_encode(['1042','1043']),'destination'=>'1042',
]);
// After checking the preview:
$result = FM_api('Form_mergeTables', [
'ids'=>json_encode(['1042','1043']),'destination'=>'1042',
'apply'=>'1','revision'=>$preview['revision'],'confirmation'=>'I am sure',
]);
Example response
{"ok":1,"revision":"7c10cfc9932bd5066252ef29f11a7fc53cc24669c418161cc48964f63b8be881b4","forms":2,"jobs":3}
Database numeric values can be JSON strings. Examples are representative; legacy application errors can use HTTP 200, so inspect the decoded response.
Validation errors describe the incompatible definition, automation, parent, answer conflict, scope or stale preview. An error is a stopped merge, not a partial-success count.
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":"permission denied"} | Missing Forms Edit. Missing Jobs Edit instead returns Jobs Edit permission is required to merge tables.; the legacy restriction returns No permission to edit Jobs. |
{"error":"form edits are disabled for this account"} | Definition edits locked. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Both preview and apply run under the shared settings transaction/lock. A preview commits no business changes. forms counts changed parent definitions; jobs counts Jobs whose answers/stock references need changes, not every selected table or scanned Job.
- Requires compatible sanitized field definitions and matching settings (metadata notes/tags/form_parents are excluded from that comparison). Blocks archived/non-Job Tables, relevant On Complete/workflow mappings, non-Job parents, worksheet parents and duplicate destination links within a parent.
- Inspects stored subform_values and stock_used references, including retained deleted/orphan Job answers. At most 2,000 candidate Jobs are allowed; over that limit is rejected rather than partially processed. Every candidate passes the actor’s Job record-scope check.
- Two populated selected tables in the same Job are a conflict even when their answers are equal. An empty destination can receive one populated source. Source keys are removed and stock_used.formTable references retargeted without adding stock or deducting it again.
- On apply, recalculates and compares the revision inside the transaction. Moves answers, rewrites parent links, retains/touches the destination and archives source definitions. No offset pagination, asynchronous worker or partial merge exists.
Side effects
- Checked transactional updates cover Job answers/stock references/sync stamps, parent definitions and form_parents, source archival, audit entries and Form Undo snapshots. Failure rolls back the transaction/savepoint; after an uncertain acknowledgement, read saved state before retrying.
See it in Fieldmotion
CRM1
The legacy merge widget retargets links through Form_editField; it does not call this checked migration route.
CRM2
In Forms, select compatible Job Tables and choose Merge Tables. Preview selects the destination and returns a revision; type I am sure to apply. Filter Form_mergeTables and distinguish apply=0 from apply=1.
Related endpoints
Form_editField— retarget one link without moving saved answers.Form_getRequestedDetails— inspect table definitions before previewing.