When to use this endpoint

Use this for a single CRM1 custom-form field. Use Invoice_updateData for CRM2 mapped layout saves.

Authentication and permissions

The request must use a logged-in CRM session or valid signed API credentials and is scoped to that tenant.

Users whose legacy crm_access mask contains bit 64 receive {"error":"no permission to access api"}. No record-owner check is made.

Parameters

ParameterTypeRequiredDescription
idIntegerYesActive invoice ID.
keyStringYesJSON object key; it is not checked against the selected invoice form.
valMixedYesValue assigned to that key.

Example request

$result = FM_api('Invoice_setField', ['id' => 981, 'key' => '42', 'val' => 'Reference text']);

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":"id, key, val parameters all required"}Any key is absent.
{"error":"cannot edit invoices that are marked Paid"}The invoice is Paid.

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

Behaviour and edge cases

  • Malformed/non-array stored JSON is replaced with a new object. An identical existing value returns warning: no change required.

Side effects

  • Rewrites the complete form_fields JSON value, advances last_edited, and fires Invoice_edit.

See it in Fieldmotion

CRM1

The invoice editor uses this route for custom invoice-form controls.

CRM2

No direct production CRM2 caller was found for this route.

Related endpoints