cancel
Showing results for 
Search instead for 
Did you mean: 

Best solution for lists that change?

tomoconnell
Champ in-the-making
Champ in-the-making
I've looked through the forums and google and I still don't know what the best practice is for this requirement.

I need a list constraint that will need to be occasionally changed. Eg, List of company managers or current products. I've had the need to use this with both metadata property fields on a document, as well as part of a workflow. The problem with constraints in the model is that I cant remove things from the model without causing issues. I have seen suggestions to get this list dynamically but would that not still cause issues if you are holding onto old files with a now invalid constraint on it?

Another solution was to use an association to cmSmiley Tongueerson for eg a list of managers, but authority.ftl out-of-the-box has no parameters for only showing users from a selected group.

Saw a few references to combo boxes as well.

I understand I am going to have to do some extending somewhere in order to solve my problem, I just don't know what way is the most efficient and reusable, I will have many other cases to use this functionality in.

Any advice or help would be appreciated.
Thanks.
2 REPLIES 2

scouil
Star Contributor
Star Contributor
Hi,

I guess the easiest for you would be to define your own custom constraint:
https://wiki.alfresco.com/wiki/Content_Model_Constraints#Writing_Further_Constraints
It would point to a java class where you would retrieve all your managers for example and make a list out of it
Fo far it's quite easy to implement.

But the part where it gets complicated is the exact same problem that the default model has: what if you remove a value that was already used by a document.

I believe (but not sure) that Alfresco will keep the value as is on the document and that trying to retrieve it programatically will return the value correctly. However the UI will generate a list where that value doesn't exists so it will display an empty value. And as soon as you edit the properties of a document you won't be able to keep the old value.

Another option might be that your java class merges the current values with the historical ones to create the list. But this can prove a longer operation and then any deleted value will still be available in the list if any document has it.

Finally, what I believe would be the best option, would be write a behaviour to catch the deletion/modification of the users and if it removes a manager from the list, then handle all the documents that had him as a value (set it to null or a default value, as you please)

cesarista
World-Class Innovator
World-Class Innovator
An easier aprox is via the useful addon:

http://addons.alfresco.com/addons/alfresco-listmanager

You have a nice interface in Share Admin for dealing with these dynamic constraint lists, that it is also possible to manage in Dictionary Data.

And yes, Alfresco will keep the value if this property is of type text on your content model. So it's not trivial when changing these properties to content that exist some time ago in your repo, but it is better for content deploys in different environments.

In the case you want to preserve the reference for a simple list, you can consider a property of type category in your model, with a custom combo selector from Share with a category path search (for avoiding problems related to the standard Share component with categories)

I posted some info about this in my blog (in spanish):

http://www.zylk.net/es/web/guest/web-2-0/blog/-/blogs/constraints-de-tipo-lista-y-variantes-en-el-mo...