Customers
Suggest the next customer account number
/a/Customer_getNextAccountNumber
Suggest a successor to the legacy highest account-number string by regrouping and incrementing its digits.
When to use this endpoint
Use Customer_getNextAccountNumber to reproduce the suggestion shown when a tenant enables automatic account-number assignment.
Treat the result as a suggestion only. The endpoint neither reserves it nor checks the final value again during customer creation.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.
The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.
Parameters
This endpoint has no operation-specific parameters.
Example request
$next = FM_api('Customer_getNextAccountNumber');
Example response
"C010"
With no existing nonblank account numbers, the response is "1". The result is a JSON string.
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. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- The endpoint first uses
Customer_getHighestAccountNumber, so only non-deleted rows participate and its string-length ordering applies. - It removes every digit to form a prefix, concatenates every digit into one number, increments that number, pads it to the original total digit count, then appends it after the prefix. Mixed formats can therefore be rearranged; for example
AB-009ZbecomesAB-Z010. - There are no caller-controlled filters or pagination.
See it in Fieldmotion
CRM1
The legacy Create Customer dialog calls this endpoint only when customer-auto-assign-account-number is enabled, then pre-fills Account Number.
CRM2
CRM2 customer and subsidiary creation flows call the highest-number endpoint followed by Customer_getNextAccountNumber. Filter Network requests by the function name.
Related endpoints
Customer_getHighestAccountNumberselects the source string.Customer_checkAccountNumberIsUniquecan preflight the suggestion immediately before use.