Skip to content

Multiple COT catalog number formats causes error with autonumbering schemes #7687

@emenslin

Description

@emenslin

Describe the bug
When trying to save a CO on ojsmnh you get a Collectionobject must have unique catalognumber in collection error. This also happens when trying to autonumber cat # in the workbench.

@melton-jason explanation:

Technically the "largest" Catalog Number in that Collection is 4355: Query: Largest CIDA Numbers (CO 62790). That CollectionObject is using the Ornithology COT, which is using the CatalogNumberString Format (which accepts any values).

Without a default COT specified when creating a new CO, Specify is using the CatalogNumberNumeric Formatter.
With the CatalogNumberNumeric Formatter, Specify is looking for Collection Objects that match any number from 0-999999999, so it would see that 4355 as the "largest" CatalogNumber.
Specify takes the number and formats it in a way that matches the CatalogNumberNumeric Formatter, so it formats it as 000004355 and then add one to it: 000004356 .
However, when Specify actually goes to save the CO with that CatalogNumber it can't because there's a CO with that CatalogNumber that already exists: CO 62809.

To Reproduce
Steps to reproduce the behavior:

  1. Open https://ojsmnhv711320251104-v7113.test.specifysystems.org/specify/
  2. Go to CO
  3. Try to save
  4. See error

To create issue from scratch on a new DB:

  1. Use the CatalogNumberNumeric format on the Collection or Collection's CollectionObjectType (COT)
  2. Define a new CollectionObjectType with a Catalog Number Format of CatalogNumberString
  3. Create a new ColllectionObject (using the CatalogNumberNumeric formatter)-- I'll assume it would be 000000002 for the example
  4. Create a new CollectionObject using the COT with the CatalogNumberString format and save it as one less than the prior CollectionObject: with the example this would be saving it as 1
  5. Attempt to create a new CollectionObject using the COT with the CatalogNumberNumeric formatter, and see the error (Uniqueness Rule Exception)
  6. This is because Specify will see 1 as the largest CatalogNumber, format it as CatalogNumberNumeric, and attempt to save the CollectionObject with the value of 000000002 (which already exists)

Expected behavior
No error should be thrown

Screenshots

02-05_09.44.mp4

Crash Report

Specify 7 Crash Report - 2026-02-05T15_45_00.904Z.txt

Please fill out the following information manually:

Metadata

Metadata

Assignees

No one assigned

    Labels

    2 - FormsIssues that are related to the form system

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions