cancel
Showing results for 
Search instead for 
Did you mean: 

Enforce no duplicates on an aspect property

rob2020
Champ in-the-making
Champ in-the-making
Hi,

I have defined a custom content type of "product" which has a mandatory custom aspect of "sku" ie SKU being the product identifer and the primary key of a product.

I'd like to ensure that this SKU aspect is unique across that content type (product) ie no duplicate product documents are allowed in.

I thought I should be using an aspect because other document types also have sku such as "product images" and "product articles".  These types are allowed to have many documents with the same SKU (they are in fact child assocations of the "product" document which is effectively the golden source of our existing products)

Is it possible to enforce a no duplicate aspect (sku) on just this document type whilst not for other document types?    I've seen use of <duplicates> tag on  child associations but haven't found it in the context of an aspect.

Thanks

Rob
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
Two options come to mind. First, you could write a custom constraint for the SKU property that would check to see if the value was already being used on an object of the product type.

A second option would be to use use a behavior to check to see if the SKU has already been set on another product object.

I think the constraint might be the first thing to try.

Jeff

rob2020
Champ in-the-making
Champ in-the-making
Thanks Jeff.

I will use your book which is sat on my desk right now as a reference whilst I give one of these a try.  I'm a big fan of your book by the way. It's fast tracked me into Alfresco.

Cheers

Rob