What´s the best way to check that two or more properties are unique?

Hi Community,

maybe somebody knows a simple solution for this use case. My Part table has the following properties. Nothing really exotic:

item_number | erp_number | major_rev | name | ..

Both item_number and erp_number shall be unique values. When I tick the unique checkbox in the ItemType definition for both properties, a combination of the two properties will be used for the uniquness check. 

There are use cases were this kind of unified uniquenss check is extremely helpful, like Part Goals. But in my use case I want to check item_number and erp_number indepented for their uniqueness. 

What´s the most easy way to achieve this? Is there a way to prevent using a Method?

Thanks for any idea!

Angela

Parents
  • We had a similar requirement elsewhere, Item ID(unique=true, but wanted to change this and make combination to be unique)+ItemType to be unique. The application we use supports multi field key, but we can do it in Aras either with the object model or with sql table.

    SQL option is to creates a table in database which stores Item ID and combination of 2 fields, from a database trigger (no method code involved, the records are created or updated based on create/update in say Part table - so latest combination is always updated to that table). You have to make sure you delete the record when Part gets deleted. When creating a new part you have to run sql to check if the same combination already exists using sql.

    If you want to avoid SQL, create a new property on the itemtype and obBeforeUpdate/Create populate the field with combination of 2 fields. And validate against the new field for each new create. Other way you can use new itemType to store combination of 2 fields too.

Reply
  • We had a similar requirement elsewhere, Item ID(unique=true, but wanted to change this and make combination to be unique)+ItemType to be unique. The application we use supports multi field key, but we can do it in Aras either with the object model or with sql table.

    SQL option is to creates a table in database which stores Item ID and combination of 2 fields, from a database trigger (no method code involved, the records are created or updated based on create/update in say Part table - so latest combination is always updated to that table). You have to make sure you delete the record when Part gets deleted. When creating a new part you have to run sql to check if the same combination already exists using sql.

    If you want to avoid SQL, create a new property on the itemtype and obBeforeUpdate/Create populate the field with combination of 2 fields. And validate against the new field for each new create. Other way you can use new itemType to store combination of 2 fields too.

Children
No Data