• Skip to primary navigation
  • Skip to main content
  • Skip to footer
ecm experts in australia

Seed Information Management

Enterprise Content Management Consultants ECM Experts

  • Services
    • Content Management
    • Collaboration
    • Business Process Management
    • Migration Services
    • Integration Services
    • Support & Maintenance
    • Pricing
  • Technology
    • Alfresco Digital Business Platform
    • Alfresco Application Development Framework
    • Cloud (PaaS)
    • Activiti
    • Flowable
    • Hyland RPA
  • Alfresco Addons
  • Case Studies
    • Industries
  • Blog
  • Contact Us
    • About

Alfresco List Constraints and Repeating Metadata Fields with Commas

July 31, 2014 By Seed IM

List Constraint for a Repeating Metadata Field and Commas

This blog is a reflection on Seed IMs experience with Alfresco when configuring a repeating (multiple) metadata field with a list of values that contain commas.

In general it is possible to use Content Model Constraints to handle lists of acceptable values for a metadata field. However, the issue we had to address was how to use constraints when commas were present in the value, (eg 2,4-d) and the metadata field is repeating. Alfresco uses commas to signify a new value when a user enters fields using Share. Therefore if you provide a dropdown which contains, for example, a value of 2,4-D, when you save the value, alfresco assumes that you are setting two values, 2 and 4-D into the multivalued metadata field. Unfortunately, the values are not valid from a constraint perspective so you cannot save them to the content item.

Solution

We tried many different options to get around this, such as escaping the comma or using share forms config “options” parameter but none of them worked, alfresco always treated 2,4-D as two values and set the metadata field accordingly. Eventually we settled on the solution to use a constraint value without a comma and use Resource bundles to present a value including a comma to the user. Therefore, the user picks a value from the list as 2,4-D but the real value saved is 2-4-D. The solution is shown below.

1) List Constraint: Create a list constraint in your custom content model.  Note that comma in 2,4-D has been replaced with – (2-4-D). 2-4-D IBE Imazapic 2-4-D …

<constraint name=”seed:activeList” type=”LIST”>
           <parameter name=”allowedValues”>
               <list>
                    <value>2-4-D IBE</value>
                    <value>Imazapic</value>
                    <value>2-4-D</value>
                …
               </list>
           </parameter>
       </constraint>

2) Configure Metadata field to use List constraint values

<!– Muti-value Metadata field that uses the constraint –>
<property name=”seed:active”>
<title>Active</title>
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>true</multiple>
<index enabled=”true”>
<atomic>true</atomic>       <!– index in the foreground –>
<stored>false</stored>       <!– store the property value in the index –>
<tokenised>true</tokenised>
</index>
<constraints>
<constraint ref=”seed:activeList”/>
</constraints>
</property>

3) Configure a Model Resource Bundle. This maps the values stored in the constraint to the Display values seen in Share for the dropdown. The space in 2-4-D IBE is escaped with value \u0020IBE as you cannot have spaces in a property name.

listconstraint.seed_activeList.2-4-D\u0020IBE=2,4-D IBE
          listconstraint.seed_activeList.Imazapic=Imazapic
          listconstraint.seed_activeList.2-4-D=2,4-D
          …

4) Configure share form to allow for selectmany control to pick up constraint values.

<field id=”seed:active” read-only=”false” mandatory=”true” label-id=”label.nuf_active”     set=”study-technical-properties” >
                  <control template=”/org/alfresco/components/form/controls/selectmany.ftl”>            </control>
       </field>

Reference

https://wiki.alfresco.com/wiki/Data_Dictionary_Guide#Model_Localization

Footer


Seed IM is a leading ECM consulting company providing powerful solutions to businesses and organisations of all sizes

Contact Us

  • Seed Information Management Pty Ltd
    90 Maribyrnong Street
    Footscray VIC 3011
  • 03 9021 0837
  • info@seedim.com.au

Articles

Semantic Content Management for Alfresco
Using Multiple Taxonomies To Browse Your Content
Records Management Using Alfresco One

Copyright © 2025 Seed Information Management Pty Ltd · Contact Us · Privacy Policy · Our Digital Media Agency is Marmoset Digital