When to use this endpoint

Use only when the caller holds the complete current table collection, such as persisting a sorted table while preserving all other tables.

Use Job_setTableCells for individual cell changes or Job_tableRowAppend for appending rows without resending the entire collection.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.

Job and form IDs refer to the authenticated account. Cross-account writes occur only through the stored outsourcing relationship on the routes that explicitly mirror changes.

The dispatcher also applies account/user and IP restrictions. A CRM session carrying a CSRF token must supply it through X-FMCSRF or _csrf; missing/incorrect tokens can be rejected before this handler runs.

Parameters

ParameterTypeRequiredDescription
job_idInteger stringYesPositive physical job ID; integer-converted. Zero and negative values fail the initial validation.
tableJSON object string or arrayYesComplete table-ID-to-row-array collection. Blank, invalid JSON and empty decoded collections are rejected. To clear one table, include its key with an empty row list, preserving all other tables. Truthy decoded scalars are not properly shape-validated.

Example request

$result = FM_api('Job_setTables', [
	'job_id'=>'1042',
	'table'=>json_encode(['302'=>[['Inspection','Passed']], '303'=>[]]),
]);

Example response

{"ok":1}

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":"table and job_id parameters are required"}job_id is nonpositive after conversion, or table is absent/null.
{"error":"no such job exists"}No active job is read.
{"error":"table parameter did not JSON-decode into an object"}table is falsey after decoding, including {} or [].
{"error":"Unable to save job"}The primary database save failed. Successful-save history and subsequent follow-ups are not run.
{"ok":1,"warning":"Job saved; follow-up incomplete. Inspect saved state before retrying.","warnings":["Job_updateCosts: Unable to save job"],"saved":1}The primary save succeeded, but a recalculation, asset rebuild, notification or outsourced mirror failed. warnings identifies the failed follow-up; any normal response fields remain present. A benign no-change result from a follow-up is not a failure. Read saved state before retrying.

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

Behaviour and edge cases

  • Overwrites all subform_values, not just the keys supplied. Omitted tables and their answers are removed from the job.
  • Serializes the top-level collection as a canonical JSON object, removing null placeholder keys. It does not verify table/form membership, cell types or row widths.
  • No concurrency token, paging, maximum row count or deduplication is supplied. Empty overall collections cannot be used to clear everything through the normal validation path.

Side effects

  • Unchecked active-job UPDATE of table answers, timestamps and edit marker, meetings-cache invalidation and generic job history.
  • Rebuilds derived asset links/movements and calls Job_updateCosts/its price follow-up; failures produce saved-state warnings. Removing stock cells does not return stock, and omitted image references do not remove files. No outsourced mirror occurs.

See it in Fieldmotion

CRM1

Sort a table on a job’s Tables page: pageJobTables.js sends all subTableVals to Job_setTables, including the newly sorted rows. widgetMergeTables.js also reads the full job and resaves tables when copying a table key.

CRM2

No direct canonical or legacy caller was found in CRM2’s source. Its Job form import/cell paths use Job_addTableRow and Job_setTableCells instead.

Related endpoints