How to impose globally unique constraint

Hi Sebastian,

It seems that the “unique” validation constraint (in the Squidex editor) only applies to values within the given schema.

I would like to impose a global unique constraint, covering all values in the app, for certain fields. What approach you would recommend for this?

Best,

Barton

Hi,

You should probably just use a guuid. Squidex unique validations are not always unique. If you make two documents very quickly we have had duplicate “unique” ids before. If this is not possible you can consider using a custom validation which can check if the value has been used in any of the relevent schemas.

Hi,

Thanks for your reply.

Regarding the GUID approach, is it possible to have a “hidden” field in a schema, such that I can generate a GUID when new content is added, but the user will never see it? Or to have a field that users cannot edit?

You can mark a field as disabled and create the ID with scripting. But I have to make an extension to the scripting extension for that. Feel free to create a feature request.

Thanks, Sebastian. I’ve added the feature request.

1 Like