Accounts and tax types
Change a nominal account code
/a/Account_setNominal
Replace one account’s nominal code after checking for an existing exact code.
When to use this endpoint
Use Account_setNominal only for CRM1’s inline Chart of Accounts edit. Matching stock codes are migrated by this call.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler calls the normal login guard but performs no additional Finance-page, client-admin, role, create, edit, or delete permission check.
All reads and writes use the authenticated tenant. CRM1 and CRM2 decide whether to show finance controls, but these handlers do not repeat those client-side checks.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible | Yes | Positive account ID. |
val | String | Yes | Trimmed nonempty replacement code, maximum 10 characters. |
Example request
$result = FM_api('Account_setNominal', [
'id' => 331042,
'val' => '4010',
]);
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":"missing or invalid parameter: id"} | The ID is absent or not positive. |
{"error":"missing or invalid parameter: val"} | The new code is absent or blank. |
{"error":"parameter too long: val. max length 10 characters"} | The replacement code exceeds 10 characters. |
{"error":"account does not exist"} | No account has that ID in the authenticated tenant. |
{"error":"duplicate nominal code"} | Another account already has the code. Re-submitting the target account’s current code succeeds as a no-op. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- An unknown positive ID is rejected before the duplicate-code check or any write.
- The schema has no uniqueness constraint; this endpoint relies on a separate lookup before updating.
Side effects
- Advances
last_editedon the target row and clears the account cache. - Updates stock rows whose nominal code exactly matches the target account’s previous nonempty code.
See it in Fieldmotion
CRM1
Open Settings → Finance. CRM1 loads and edits the Chart of Accounts, Tax Types, and Tax Groups from this endpoint family; filter browser developer tools for the exact function name. Edit an existing Nominal Code cell to send Account_setNominal.
CRM2
CRM2 does not call this setter; its Save action sends the complete account list to Account_updateData.
Related endpoints
Account_getDetailsresolves the resulting code.Account_deleteclears matching stock codes when deleting.