Unique constraint on combination of two attributes

Hi, I want to place unique constraints on combination of two attributes in database, Like i have a coupon code and a 4 digit number  as  an attributes, So now i want the  unique constraints on combination of Coupon code and last a 4 digit number, just like  UNIQUE(column1, column2); in SQL. Thanks 
1 answers

Two options:

  • Create a BeforeCommit-event on the entity. Make that microflow throw an error if the combination of the two values is not unique;
  • Create an extra attribute, make it a calculated one, and set a unique restriction on that one.