Invoices
Build a credit-note filename
/a/CreditNote_getFilename
Build a filesystem-safe base filename from an active credit note’s number.
When to use this endpoint
Use this when naming a credit-note download independently of CreditNote_getPdf, which adds the same filename automatically.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session and is scoped to the authenticated tenant.
The tenant setting accounting_credit_notes must equal 1. Otherwise the handler returns {"error":"Credit Notes are not enabled for this account"}.
Users whose legacy crm_access mask contains bit 64 are denied. The handler does not enforce the CRM2 pageCreditNotes role permission, ownership, or department scope.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer-compatible | Yes | Active credit-note ID. |
Example request
$name = FM_api('CreditNote_getFilename', ['id' => 311]);
Example response
{
"ok": 1,
"value": "CN-1042"
}
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":"credit note does not exist"} | The ID is absent or soft-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
- Runs of characters outside letters, digits, dot, underscore, and hyphen become a hyphen; leading/trailing hyphens are removed.
- A blank number becomes
credit-note-{id}. If sanitization still produces blank text, the fallback iscredit-note.
See it in Fieldmotion
CRM1
No production CRM1 caller was found.
CRM2
No direct production CRM2 caller was found; the PDF endpoint calls the same filename helper internally.
Related endpoints
CreditNote_getPdfrenders the document and includes this base filename.