Stock catalog fields and lookups
Find duplicate stock names and optionally normalize them
/a/Stock_listDuplicateNames
Return lowercased repeated stock names, optionally renaming active stock before checking.
When to use this endpoint
Use to identify names requiring review before an integration’s duplicate-name repair. This call does not append uniqueness suffixes or merge stock.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. This handler requires both a user identity and tenant context; it adds no stock-page, finance or administrator permission check.
All queries use the authenticated tenant. API signing and session CSRF checks still apply; see Getting started.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
trim | Boolean-compatible scalar | No | Explicit true/1/on/yes (case-insensitive strings) enables normalization. Omitted, false, zero, blank, null or unrecognized values are read-only; presence alone never enables writes. |
Example request
$duplicates = FM_api('Stock_listDuplicateNames', []);
Example response
[{"name":"filter cartridge"}]
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. |
[] | No lower(name) group contains more than one non-deleted row. |
{"error":"stock catalog write failed"} | A primary write or required history insert fails; the transaction rolls back. |
{"error":"stock catalog read failed"} | A checked read fails; a normalization or write transaction is rolled back. |
{"error":"stock catalog transaction failed"} | Transaction start or commit fails; no success is returned. |
{"error":"stock catalog operation failed"} | Unexpected database/runtime failure during the transaction. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Explicit normalization locks affected non-deleted rows, SQL-trims names and uses code when the trimmed result is exactly empty. NULL names are not selected; a null code can leave a null normalized name. Database TRIM semantics are preserved.
- Grouping uses lower(name), includes archived stock, excludes deleted stock and returns no IDs/counts. Database collation affects grouping; no ordering or paging.
- Only changed names receive timestamps, edited_uuid and history. All checked normalization writes and history commit together; each changed ID receives a post-commit Stock_edit event.
- Normalization can still leave duplicates. The browser appends uniqueness suffixes with Stock_setName. No extra client-admin or integration feature guard.
- No direct mobile caller was found in the current app JavaScript or
m/wwwintermediary. The app receives stock throughsyncDownloads, which selects non-deleted stock by edit timestamp; these calls are not the app synchronization protocol.
Side effects
- With an explicit enabled trim value, checked changed-row writes stamp last_edited and edited_uuid=Stock_listDuplicateNames and record name history; invalidate stocks cache.
- Runs configured Stock_edit per changed stock ID after commit. Omitted/disabled trim is read-only; no quantity or supplier-link mutation.
See it in Fieldmotion
CRM1
The QuickBooks connection flow invokes widgetStockNameDeduplicator, which sends trim=1. Its Correct Automatically action subsequently loads stock and calls Stock_setName for suffixes.
CRM2
The QuickBooks connection widget includes the same duplicate-name workflow and sends trim=1. The follow-up Stock_setName calls, not this lookup, make names unique.
Related endpoints
Stock_setNamerenames a reviewed single item.