You should prevent users to add duplicated records into the database, especially in parent and linking tables.
You can achieve it using index, appended to the database table.
Let´s have entity
ProductCathegory with a field
Name. (There are names of cathegories of products stored in).
Create the index:
Right click on the entity
ProductCathegoryand Create > New Index.
In the opened form set the Name, e.g. to
ix_ProductCathegoryand set the IsUnique attribute to
Now you can see created index
ix_ProductCathegoryin the Model browser tree (in folder
Add the field:
On the index
ix_ProductCathegorycreate New > Index Field.
In the form set in Field the name of column, that you want to be indexed. In this case select from list field
(Note, that the name of index changed to
0_Nameafter selection of Field
Save it and deploy index to database (using Deployment Script Generator).
You should see this in the Model Browser:
Now, if user wants enter duplicated name of product cathegory, the user interface returns message:
Could not add ProductCathegory. You entered duplicate data and don´t save the record.
Using combined index for more columns in the same entity
You can use the same process for avoiding duplicated combinations of two or more columns, e.g. referenced fields in linking tables.
Let´s have entity
SalesOrder with columns
On the entity
SalesOrder create New > Index (call it e.g.
ix_SalesOrder. Don´t forget to set the attribute IsUnique to value
First on this newly created index create New > Index Field for the field
Second on the same index create the second New > Index Field for the field
Save it and deploy into the database.
Now the applicatin prevents the user from adding duplicated combination of product and producer.