Validation of new record

0
Hi all, I have a product entity with about 50 fields. When the user adds a new product record, I would like to check, if the product record already exists. To that end, I need to compare the fields of the newly created product record with fields of the already existing product record fields in the data base. I can use a needed loop and cycle through all product records and within each record compare all fields. So entry of each field can be doublicated, but the combination of entries must be unique for the product records. I am wondering, if there is a smarter way to do that. Any suggestions?  
asked
2 answers
1

You could consider to retrieve and then count the result to save performance. For example: retrieve your ProductList from database with an Xpath on the lines of [id != $Product and "(all attributes that need to be checked)"].

 

This will result in a list that you count immediately with an AggregateList function. If your count > 0 then this means there are records with duplicate attribute values. I think looping over a (large) list could have quite an impact on your performance if the list grows over time.

 

Hope this helps!

answered
1

Probably best to add an extra attribute that should be unique for every product, something like an ISBN, EAN. You could base it on the value of other attributes.

answered