docspell icon indicating copy to clipboard operation
docspell copied to clipboard

Add unique option to custom data

Open eresturo opened this issue 4 years ago • 4 comments

Hi, I have a custom field for which I would like to make sure it is/stays unique. Is it possible to add a corresponding option to the definition of a field, or am I the only one who needs something like this? Cheers Eresturo

eresturo avatar Jan 04 '21 20:01 eresturo

It didn't occur to me as important :) But I can see that this would be helpful in some cases. I probably wouldn't try to enforce it at the db-level. Maybe the server doing a check when setting a value is an option.

eikek avatar Jan 04 '21 22:01 eikek

Great idea! In addition to it, it would be useful to have a composite unique constraint. I've got invoices with an invoice number, but I can have the same invoice number from an other organisation.

stephanvierkant avatar Mar 19 '22 08:03 stephanvierkant

The classic use-case here is the ASN field.

madduck avatar Sep 08 '23 22:09 madduck

If the ASN is generated outside of docspell, its source already guarantees uniqueness. most of the time I'd think :). like these nice stamps that generate consecutive numbers.

These things get quickly very complex and they will be hard to understand after a while. I think I might add a uniqueness option for a field, but not in combination with other fields/metadata. For invoices, in theory you could have same invoice numbers from different companies. But in my eyes, this is a very rare reality and not a problem at all. If that occurs, you might see two or three documents in the results and one look will identify the one you want. If you know the company, just add a constraint for it. For me this is not a strong enough case for adding more things atm.

eikek avatar Sep 09 '23 18:09 eikek