cancel
Showing results for 
Search instead for 
Did you mean: 

Create a rule to do an action depending on the document type

julian
Champ in-the-making
Champ in-the-making
Hi,

I am trying to create a rule in ALfresco One (Alfresco Enterprise v4.2.0).
I have a custom model like this:


<types>
      <type name="myCustomModel:docType1">
         <parent>cm:content</parent>
         <mandatory-aspects>
            <aspect>cm:author</aspect>
            <aspect>myCustomModel:details</aspect>
         </mandatory-aspects>
      </type>

<types>



I want to do a rule to move my document if it is a type "myCustomModel:docType1". But it doesn't work if I choose "cm:type" contains "myCustomModel:docType1" or "docType1"…
The rule works if I make the action depending on the title (but it's not what I want).

Is the custom document type stored in another metadata?

Thanks in advance.
6 REPLIES 6

kaynezhang
World-Class Innovator
World-Class Innovator
At step One - Select Conditions ,please choose "Content of type or sub-type" as condition,It'll work.

julian
Champ in-the-making
Champ in-the-making
Thanks, I tried this solution but in the list of propositions of "Content of type or sub-type" I haven't my custom type. Only "Content", "Folder"… but not my custom type.
Did I miss something?

rjohnson
Star Contributor
Star Contributor
Have you put your custom type in share-config-custom.xml as a sub type of cm:content?


      <types>
         <type name="cm:content">
            <subtype name="YOUR-TYPE_HERE"/>
       </types>

julian
Champ in-the-making
Champ in-the-making
Yes I have.
In my  share-config-custom.xml I have:

<types>
    <type name="cm:content">
      <subtype name="myCustomModel:docType1" />
      <subtype name="myCustomModel:docType2" />
      <subtype name="myCustomModel:docType3" />
      <subtype name="myCustomModel:docType4" />
      <subtype name="myCustomModel:docType5" />
      <subtype name="myCustomModel:docType6" />
    </type>

         <type name="cm:folder">
         </type>

         <type name="trx:transferTarget">
            <subtype name="trx:fileTransferTarget" />
         </type>
      </types>


But in the rule configuration when I choose "Content of type or sub-type" I have only the choice for: content, folder, transfer target and file transfert target. I don't see docType1,…,docType6.

When I edit a file, I can choose these different types (docType1,…,docType6).

Do you have an idea about what is missing?

Thanks.

rjohnson
Star Contributor
Star Contributor
Well. If you have done that the only other thing I can think of is that you may need a message in a .properties file along the lines:-


type.myCustomModel_docType1=Document description


Now, I would have expected the lack of this to merely result in your document types being displayed as myCustomModel:docType1 etc in the drop down list.

You appear to have set up your documents exactly as I have and mine definately apear in the "Types and sub-types" list on the rules.

julian
Champ in-the-making
Champ in-the-making
I have all these features Smiley Sad
In fact my subtypes are well known by Alfresco because in the "change type" dropdown list in the file edition I can see my subtypes. They are only not visible in rule configuration.

My "myCustomModel.properties" (in /alfresco/tomcat/shared/classes/alfresco/extension/)

myCustomModel_contentmodel.type.myCustomModel_docType1=Doc type 1
myCustomModel_contentmodel.type.myCustomModel_docType2=Doc type 2
myCustomModel_contentmodel.type.myCustomModel_docType3=Doc type 3
myCustomModel_contentmodel.type.myCustomModel_docType4=Doc type 4
myCustomModel_contentmodel.type.myCustomModel_docType5=Doc type 5
myCustomModel_contentmodel.type.myCustomModel_docType6=Doc type 6

I also tried with:

type.myCustomModel_docType1=Doc type 1
type.myCustomModel_docType2=Doc type 2
type.myCustomModel_docType3=Doc type 3
type.myCustomModel_docType4=Doc type 4
type.myCustomModel_docType5=Doc type 5
type.myCustomModel_docType6=Doc type 6


My "myCustomModel.xml" (in /alfresco/tomcat/shared/classes/alfresco/extension/)

<?xml version="1.0" encoding="UTF-8"?>
<model name="myCustomModel:contentmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>My custom Model</description>
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
   </imports>
   <namespaces>
      <namespace uri="myCustomModel.model" prefix="myCustomModel" />
   </namespaces>

   <!– Types –>   
   <types>
      <type name="myCustomModel:docType1">
         <parent>cm:content</parent>
         <mandatory-aspects>
            <aspect>cm:author</aspect>
            …
         </mandatory-aspects>
      </type>
                …
      <type name="myCustomModel:docType6">
         <parent>cm:content</parent>
         <mandatory-aspects>
            <aspect>cm:author</aspect>
            …
         </mandatory-aspects>
      </type>
   </types>
   <aspects>
   …
   </aspects>
   
</model>



My "share-config-custom.xml" (in /alfresco/tomcat/shared/classes/alfresco/web-extension/)

<alfresco-config>
   …
   <!– CUSTOM –>
   <config evaluator="string-compare" condition="DocumentLibrary">
      <types>
         <type name="cm:content">
            <subtype name="myCustomModel:docType1" />
            <subtype name="myCustomModel:docType2" />
            <subtype name="myCustomModel:docType3" />
            <subtype name="myCustomModel:docType4" />
            <subtype name="myCustomModel:docType5" />
            <subtype name="myCustomModel:docType6" />
         </type>
      </types>
   </config>
   <config replace="true" evaluator="string-compare" condition="AdvancedSearch">
      <advanced-search>
         <forms>
            <form labelId="search.form.label.docType1">myCustomModel:docType1</form>
            …
            <form labelId="search.form.label.docType6">myCustomModel:docType6</form>
         </forms>
      </advanced-search>
   </config>
   …
   <config evaluator="model-type" condition="myCustomModel:docType1">
      <forms>
         <form id="search">
            <field-visibility>
               <show id="cm:author" />
               <show id="cm:name" />
               …
            </field-visibility>
            <appearance>
               <field id="cm:author">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="cm:name">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               …
            </appearance>
         </form>
      </forms>
   </config>
   …
   <config evaluator="model-type" condition="myCustomModel:docType6">
      <forms>
         <form id="search">
            <field-visibility>
               <show id="cm:author" />
               <show id="cm:name" />
               …
            </field-visibility>
            <appearance>
               <field id="cm:author">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="cm:name">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               …
            </appearance>
         </form>
      </forms>
   </config>
</alfresco-config>


Did I miss a thing? Do you have the same?

Thanks in advance