When to use this endpoint

Use this for a purchase-order or customer-order reference attached to an invoice.

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
idPositive integer-compatibleYesActive invoice ID, normalized to an integer before lookup.
valStringYesTrimmed replacement value, maximum 32 bytes under PHP strlen. Empty clears it.

Example request

$result = FM_api('Invoice_setOrderNo', ['id' => 981, 'val' => 'PO-4421']);

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":"order_no is too long. Max length 32"}The trimmed value exceeds 32 bytes.
{"error":"invoice does not exist"}The invoice is absent or deleted.

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

Behaviour and edge cases

  • Paid invoices are editable through this route. An unchanged value returns warning: no change necessary.

Side effects

  • Updates the order number and edit metadata and fires Invoice_edit.

See it in Fieldmotion

CRM1

The main invoice editor calls this route.

CRM2

No direct production CRM2 caller was found for this route.

Related endpoints