Question
I started developing a small warehouse management and production needs calculation block for supply. Everything is based on the fact that there cannot be two identical items in one request. This is because when adding or modifying, a single related record is created in the general needs table (the code searches for a record in it, deletes it, and inserts a new one).
Since the item names in the Order table are of the Select type, data entry uniqueness is not automatically tracked.
Is there any code or action code that can block the entry of duplicates?
Answer
You can place an action code for adding/modifying that will search for the current field value in the current table and issue an error if there are duplicates.
Action code in the table where we prohibit duplicates in the field, the values of which cannot be duplicated with active triggers when adding and modifying:
=: if(condition: $find != ""; then: $err)
find:select(table: $#ntn; field: 'id'; where: 'item' = $#nfv; where: 'id' != #id)
err: errorException(text: "Already have in this order")