Is there any way to apply a unique constraint on an Ontology property?
Hi there! As far as I know, there isn’t a direct way to apply a unique constraint on an ontology property.
However, if your object is read-only, you can apply an expectation check on the column of your backing dataset to ensure the ontology property is unique. You can find more details in the Foundry documentations on how to do this (In Pipeline Builder; In Code repo).
If your object is editable, only the primary key (PK) of an object is automatically enforced as unique. If you try to create a new object with the same PK, an error will be thrown to prevent the creation of the duplicate object. To ensure a non-PK property is unique, you’ll likely need to write a function that implements a quick clash-checking logic. Your function then will also have the freedom to handle exactly what to do when a duplicate property is detected, such as throwing an error to inform the user.
Depending on the workflow you’re trying to create, we might have additional ways to help. Please feel free to provide more details if needed!