How link context model value to data list item in alfresco?

493 views Asked by At

The problem

There is a content model with conractType property, and data list with conractType column. It is needed to point contextModel.conractType to dataList.conractType. E.g. before insert a property value it should be checked that this valu is present in data list. Also use should select property value from drop down list which corresponds to data list values.

My solution

When try to link model property with data list type directly:

<!-- DataLists-->
<type name="sc:contractType">
    <title>Options</title>
    <parent>dl:dataListItem</parent>
    <properties>
        <property name="sc:type">
            <title>Type</title>
            <type>d:text</type>
        </property>
    </properties>
</type>

<!-- workflow model-->
<type name="sc:startProcesstask">
    <parent>bpm:startTask</parent>
    <properties>
        <property name="sc:helloName">
            <type>d:text</type>
            <mandatory>true</mandatory>
            <multiple>false</multiple>
        </property>
        <!-- Error after adding this property -->
        <property name="sc:requestCategory">
            <type>sc:contractType</type>
            <mandatory>true</mandatory>
            <multiple>false</multiple>
        </property>
    </properties>
</type>

I got an error:

Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 09180002 Property type 'sc:contractType' of property 'sc:requestCategory' is not found

So it seems that I need to create:

  1. Custom validator which check input value
  2. Custom ui element which retrieve all possible list values from contractType column.

Question 1

In this case how to link validator and ui element properly? E.g. data list has type and UUID. Link to UUID is hardcode, but link to type lead to unexpected situation when there is more then one list with values. May be it is needed to have additional binding between list data type and model?

Question 2

I think this problem is common, but it is extremelly dificult to find any piece of code. (A lot of code with separate contextn model and data lists, but no together) Does alfresco provide a build-in solution for link content model property value to data list?

1

There are 1 answers

1
Sachin  Mesare On BEST ANSWER

Alfresco's Dictionary has defined several data types that can be used while defining properties in content model Properties

So it wont accept the type that you have defined.

In order to achieve your requirement, you can go for defining sc:requestCategory as child association of sc:startProcesstask

your modified model will looks like:

<!-- DataLists-->
<type name="sc:contractType">
    <title>Options</title>
    <parent>dl:dataListItem</parent>
    <properties>
        <property name="sc:type">
            <title>Type</title>
            <type>d:text</type>
        </property>
    </properties>
</type>

<!-- workflow model-->
<type name="sc:startProcesstask">
    <parent>bpm:startTask</parent>
    <properties>
        <property name="sc:helloName">
            <type>d:text</type>
            <mandatory>true</mandatory>
            <multiple>false</multiple>
        </property>
    </properties>
   <associations>
       <child-association name="sc:requestCategory"">
           <target>
              <class>sc:contractType</class>
              <mandatory>true</mandatory>
              <many>false</many>
            </target>
        </child-association>
    </associations>
</type>