AnsweredAssumed Answered

Custom model, tags and custom search form ?

Question asked by nthiry on Aug 13, 2015
Hi,

I am brand new on this forum and using Alfresco 5.0d. I already found a lot of answers, thanks to all for sharing your knowledge !

I followed the tutorial on content model and I have a question on tags and custom search form.

I added the possibility to add a tag to my custom model and everything is fine until I want to display all documents that are linked to a tag.

In shared files, Alfresco display that I have 5 documents tagged with 'test', but when I click on it, Alfresco only display one document, the one that is not linked to my "Invoice" model.

Also when I try to use the custom search form defined below, I have no document matching when I select 2015 for my:yearCompt for example…

Everything is persisted in the database and Alfresco display it when I look at the document properties, so I don't understand why it isn't showing when I search for it.

Below are my definitions in customModel.xml and share-config-custom.xml.

Thanks !

Nicolas.



customModel.xml

<constraints>
      <constraint name="my:invoiceListConstraint" type="LIST">
         <parameter name="allowedValues">
            <list>
               <value>Facture Fournisseur</value>
               <value>Facture Kalyss</value>
               <value>Facture sous-traitant</value>
               <value>Commercial</value>
               <value>RH</value>
               
            </list>
         </parameter>
      </constraint>
      <constraint name="my:yearComptListConstraint" type="LIST">
         <parameter name="allowedValues">
            <list>
               <value>2015</value>
               <value>2016</value>
               <value>2017</value>
               <value>2018</value>
            </list>
         </parameter>
      </constraint>
            
      <constraint name="my:trimesterListConstraint" type="LIST">
         <parameter name="allowedValues">
            <list>
               <value></value>
               <value>1er trimestre</value>
               <value>2e trimestre</value>
               <value>3e trimestre</value>
               <value>4e trimestre</value>
            </list>
         </parameter>
      </constraint>
   </constraints>

<types>
      <!– Enterprise-wide generic document type –>
      <type name="my:doc">
         <title>MyCompany Generic Document</title>
         <parent>cm:content</parent>
         <mandatory-aspects>
            <aspect>cm:generalclassifiable</aspect>
            <aspect>cm:taggable</aspect>
         </mandatory-aspects>
      </type>
      <type name="my:invoice">
         <title>MyCompany Factures</title>
         <parent>my:doc</parent>
         <properties>
            <property name="my:invoiceText">
               <type>d:text</type>
            </property>
            <property name="my:invoiceDet">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
               <constraints>
                  <constraint ref="my:invoiceListConstraint" />
               </constraints>
            </property>
            <property name="my:yearCompt">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
               <constraints>
                  <constraint ref="my:yearComptListConstraint" />
               </constraints>
            </property>
            <property name="my:trimester">
               <type>d:text</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
               <constraints>
                  <constraint ref="my:trimesterListConstraint" />
               </constraints>
            </property>
         </properties>
         <mandatory-aspects>
            <aspect>cm:taggable</aspect>
         </mandatory-aspects>
      </type>
   </types>

and here is the share-config-custom.xml :

<!– Form customization for invoice –>   

   <config evaluator="model-type" condition="my:invoice">
      <forms>
         <form>
            <field-visibility>
               <show id="cm:name" />
               <show id="my:invoiceText" />
               <show id="my:invoiceDet" />
               <show id="my:yearCompt" />
               <show id="my:trimester" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
               <show id="cm:taggable" force="true" />
            </field-visibility>
            <appearance>
               <field id="cm:taggable">
                  <control>
                     <control-param name="compactMode">true</control-param>
                     <control-param name="params">aspect=cm:taggable</control-param>
                     <control-param name="createNewItemUri">/api/tag/workspace/SpacesStore</control-param>
                     <control-param name="createNewItemIcon">tag</control-param>
                  </control>
               </field>
               <field id="my:invoiceText" label="Résumé" />
               <field id="my:invoiceDet" label="Type de document archive" />
               <field id="my:yearCompt" label="Année archivage" />
               <field id="my:trimester" label="Trimestre comptable" />
            </appearance>
         </form>
      </forms>
   </config>


   <config evaluator="node-type" condition="my:invoice">
      <forms>
         <form>
            <field-visibility>
               <show id="cm:name" />
               <show id="my:invoiceText" />
               <show id="my:invoiceDet" />
               <show id="my:yearCompt" />
               <show id="my:trimester" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
               <show id="cm:taggable" force="true" />
            </field-visibility>
            <appearance>
               <field id="cm:taggable">
                  <control>
                     <control-param name="compactMode">true</control-param>
                     <control-param name="params">aspect=cm:taggable</control-param>
                     <control-param name="createNewItemUri">/api/tag/workspace/SpacesStore</control-param>
                     <control-param name="createNewItemIcon">tag</control-param>
                  </control>
               </field>
               <field id="my:invoiceText" label="Résumé" />
               <field id="my:invoiceDet" label="Type de document archive" />
               <field id="my:yearCompt" label="Année archivage" />
               <field id="my:trimester" label="Trimestre comptable" />
            </appearance>
         </form>
      </forms>
   </config>
   
      <!– Custom search form for invoice –>
   <config replace="true" evaluator="string-compare" condition="AdvancedSearch">
      <advanced-search>
         <!– Forms for the advanced search type list –>
         <forms>
            <form labelId="search.form.label.cm_content" descriptionId="search.form.desc.cm_content">cm:content</form>
            <form labelId="search.form.label.cm_folder" descriptionId="search.form.desc.cm_folder">cm:folder</form>
         <!– Nouvelle recherche pour my:invoice –>
         <form labelId="search.form.label.my_invoice" descriptionId="Recherche archives">my:invoice</form>
         </forms>
      </advanced-search>
   </config>  
     
   <config evaluator="model-type" condition="my:invoice">
      <forms>
         <!– Search form –>
         <form id="search">
            <field-visibility>
               <show id="cm:name" />
            <show id="my:invoiceText" />
            <show id="my:invoiceDet" />
            <show id="my:yearCompt" />
            <show id="my:trimester" />
         </field-visibility>
         <appearance>
            <field id="my:invoiceText" label-id="Résumé">
                <control template="/org/alfresco/components/form/controls/textfield.ftl" />
                </field>
            <field id="my:invoiceDet" label-id="Type de document archive">
                <control template="/org/alfresco/components/form/controls/selectmany.ftl" />
                </field>
             <field id="my:yearCompt" label-id="Année archivage">
                <control template="/org/alfresco/components/form/controls/selectmany.ftl" />
                </field>
            <field id="my:trimester" label-id="Trimestre comptable">
                <control template="/org/alfresco/components/form/controls/selectmany.ftl" />
                </field>
         </appearance>
         </form>
      </forms>
   </config>
         <!– Custom search form for invoice –>

<!– End of Form customization for invoice –>

Outcomes