Invoices
Set an invoice order number
POST
/a/Invoice_setOrderNo
Replace an invoice order number after trimming whitespace and enforcing its 32-character limit.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer-compatible | Yes | Active invoice ID, normalized to an integer before lookup. |
val | String | Yes | Trimmed 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
| 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":"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
Invoices_getDataTablesupplies paginated CRM2 invoice rows and IDs.Invoices_getDTis the CRM1 invoice-list counterpart.