cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic LIST Constraint

mvidev
Champ in-the-making
Champ in-the-making
I have heard it is possible to configure a LIST constraint within a model file to reference another file to allow for a dynamic list without having to edit the model file itself and restart the Alfresco server. I cannot find the syntax to do this. Is it possible and if not are there other ways to allow for a dynamic LIST constraint within a custom model? Thank you.
6 REPLIES 6

jpotts
World-Class Innovator
World-Class Innovator
Jean Barmash's original blog post was always the best example we had of this, but the blog post has been archived.

Someone copied it into a forum thread here:
https://forums.alfresco.com/en/viewtopic.php?f=19&t=43663

I'll see if we can find that blog post and move it to the wiki.

Jeff

matjazmuhic
Champ on-the-rise
Champ on-the-rise
Note that dynamic CONSTRAINT list is not such a good idea since removing item from the constraint list which is used will cause integrity violation error.

A better approach in my oppionion is to define a webscript which reads from some source and returns a JSON (maybe XML) list. Then create (if using Share) form control which will connect to that webscript and render a drop down list from that.

This isn't a secure implementation since anyone who knows how to use firebug could add their own items. but you can solve this by defining a onUpdate policy for your content type and checking if the property is in the list that webscript returns.


It's not a perfect solution, but if you intend to remove items from constraint list and don't want to cause integrity violation errors you could do something like this instead.

mvidev
Champ in-the-making
Champ in-the-making
Thank you both for your replies.

Our use case does not call for removing entries. We will programmatical import a large amount of data that falls into several dozen different catagories. The software will automatically determine the category of each entry and we would like to automatically put them into the data model list constraint. After import, the users could use the drop-down to restrict their Alfresco searches based on category. Also other external programs could access the data model for a list of the supported categories.

The categories will vary from customer to customer, so being able to automatically build and archive the category list greatly reduces the user's complexity. Also, the ability to store the category list in Alfresco as part of the data model keeps it close to the archived documents and available to any external source via CMIS regardless of the client used to view the data.

matjazmuhic
Champ on-the-rise
Champ on-the-rise
Ok. I just had to say that to cover the case… Smiley Happy

sharifu
Confirmed Champ
Confirmed Champ

sharifu
Confirmed Champ
Confirmed Champ
Note that dynamic CONSTRAINT list is not such a good idea since removing item from the constraint list which is used will cause integrity violation error.

A better approach in my oppionion is to define a webscript which reads from some source and returns a JSON (maybe XML) list. Then create (if using Share) form control which will connect to that webscript and render a drop down list from that.

This isn't a secure implementation since anyone who knows how to use firebug could add their own items. but you can solve this by defining a onUpdate policy for your content type and checking if the property is in the list that webscript returns.


It's not a perfect solution, but if you intend to remove items from constraint list and don't want to cause integrity violation errors you could do something like this instead.


If you was to use the dynamic constraint. what if you never deleted a value but just added? also what if these values got re-arranged for example alphabetically the order of the values would change so does this affect indexing or integrity violations or anything else?