cancel
Showing results for 
Search instead for 
Did you mean: 

custom advanced search form works on one machine and not another

abruzzi
Champ on-the-rise
Champ on-the-rise
I'm in the process of building a some custom project tracking into alfresco, and learning development at the same time.  I have an aspect that contains certain pieces of meta data about a project, and I would like to be able to search in those fields, but I would rather not clutter the usual cm:content field.  I'm using the maven development setup, but I cant test searching on my dev environment because I don't have solr hooked in, so I packaged up the amps and deployed them to our test server.

Unfortunately the advanced search form (which was displaying properly on the maven dev instance) gives me an error on the test server. I turned on a lot of debugging, and got the following lines when I tried to select the custom advanced search form:


10:02:42,967 DEBUG [org.alfresco.repo.jscript.ScriptLogger] Generating form for item:
10:02:42,967 DEBUG [org.alfresco.repo.jscript.ScriptLogger]    kind = type
10:02:42,967 DEBUG [org.alfresco.repo.jscript.ScriptLogger]    id = cm:content
10:02:42,967 DEBUG [org.alfresco.repo.jscript.ScriptLogger] fields = dac:itproject-title,dac:itproject-department
10:02:42,968 DEBUG [org.alfresco.repo.forms.FormServiceImpl] Retrieving form for item: [type]cm:content
10:02:42,968 DEBUG [org.alfresco.repo.forms.processor.AbstractFormProcessor] Checking processor org.alfresco.repo.forms.processor.action.ActionFormProcessor@63d9b9c (active=true, matchPattern=action) for applicability for item '[type]cm:content', result = false
10:02:42,968 DEBUG [org.alfresco.repo.forms.processor.AbstractFormProcessor] Checking processor org.alfresco.repo.forms.processor.node.NodeFormProcessor@2a7afb2f (active=true, matchPattern=node) for applicability for item '[type]cm:content', result = false
10:02:42,968 DEBUG [org.alfresco.repo.forms.processor.AbstractFormProcessor] Checking processor org.alfresco.repo.forms.processor.node.TypeFormProcessor@7000e072 (active=true, matchPattern=type) for applicability for item '[type]cm:content', result = true
10:02:42,968 DEBUG [org.alfresco.repo.forms.processor.FormProcessorRegistry] Returning applicable processor: org.alfresco.repo.forms.processor.node.TypeFormProcessor@7000e072 (active=true, matchPattern=type)
10:02:42,968 DEBUG [org.alfresco.repo.forms.processor.FilterRegistry] Returning active filters: [org.alfresco.module.org_alfresco_module_rm.forms.RecordsManagementTypeFormFilter@71b4b06a (active=true)]
10:02:42,968 DEBUG [org.alfresco.repo.forms.processor.node.TypeFormProcessor] Generating form for: ClassDef[name={http://www.alfresco.org/model/content/1.0}content]
10:02:42,968 DEBUG [org.alfresco.repo.forms.processor.node.TypeFormProcessor] Ignoring unrecognised field "dac:itproject-title"
10:02:42,968 DEBUG [org.alfresco.repo.forms.processor.node.TypeFormProcessor] Ignoring unrecognised field "dac:itproject-department"
10:02:42,968 DEBUG [org.alfresco.repo.forms.processor.node.TypeFormProcessor] Generated form: org.alfresco.repo.forms.Form@6d8fee0e (item=[type]cm:content, type=cm:content, url=/api/classes/cm_content, submissionUrl=null, fieldGroups=null
fieldDefinitions=null
formData=null)
10:02:42,969 DEBUG [org.alfresco.repo.forms.processor.FilterRegistry] Returning active filters: [org.alfresco.module.org_alfresco_module_rm.forms.RecordsManagementTypeFormFilter@71b4b06a (active=true)]
10:02:42,970 DEBUG [org.alfresco.repo.jscript.ScriptLogger] java.lang.NullPointerException: null
10:02:42,970 DEBUG [org.alfresco.repo.jscript.ScriptLogger] Returning 500 status code

So it looks like it isn't seeing the fields: dac:itproject-title and dac:itproject-department.  The custom model does seem to be working fine though, because I can apply the aspect to a file, and modify the metadata.

On the maven dev instance (both the dev instance and the test server are running 4.2.1 enterprise) it looks normal (have attached images of how it displays on the dev instance.)  When the amps are moved to the test server, I see an extra option in the advanced search selector, but when I select the "IT Projects" form, the above errors get logged, and the form displays the keywords box and the followint text below it in red:

"An error occurred when the form was about to be displayed"

So here are what I believe to be the relevant config files:

dac-itprojects (model files)

<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<model name="dac:itprojectaspect" xmlns="http://www.alfresco.org/model/dictionary/1.0">

    <!– Optional meta-data about the model –>
    <description>IT Project Tracking Model</description>
    <author>Geof Abruzzi</author>
    <version>1.0</version>

    <!– Imports are required to allow references to definitions in other models –>
    <imports>
        <!– Import Alfresco Dictionary Definitions –>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
        <!– Import Alfresco Content Domain Model Definitions –>
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
        <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
    </imports>

    <!– Introduction of new namespaces defined by this model –>
    <namespaces>
        <namespace uri="http://www.donaanacounty.org/model/donaanacounty/1.0" prefix="dac" />
    </namespaces>

    <aspects>
        <aspect name="dac:itproject">
            <title>IT Project</title>
            <properties>
                <property name="dac:itproject-title">
                    <type>d:text</type>
                    <mandatory>true</mandatory>
                    <index enabled="true">
                        <atomic>true</atomic>
                        <stored>false</stored>
                        <tokenised>true</tokenised>
                    </index>
                </property>
                <property name="dac:itproject-department">
                    <type>d:text</type>
                    <mandatory>false</mandatory>
                    <index enabled="true">
                        <atomic>true</atomic>
                        <stored>false</stored>
                        <tokenised>true</tokenised>
                    </index>
                </property>
                <property name="dac:itproject-inceptdate">
                    <type>d:date</type>
                    <mandatory>false</mandatory>
                </property>
                <property name="dac:itproject-completedate">
                    <type>d:date</type>
                    <mandatory>false</mandatory>
                </property>
            </properties>
            <associations>
                <association name="dac:itproject-owner">
                    <source>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>
                <association name="dac:itproject-itmanager">
                    <source>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>
            </associations>
        </aspect>
    </aspects>
</model>

share-config-custom

<alfresco-config>
    <!– Document Library config section –>
    <config evaluator="string-compare" condition="DocumentLibrary">

        <aspects>
            <!– Aspects that a user can see –>
            <visible>
                <aspect name="dac:itproject" />
            </visible>

            <!– Aspects that a user can add. Same as "visible" if left empty –>
            <addable>
            </addable>

            <!– Aspects that a user can remove. Same as "visible" if left empty –>
            <removeable>
            </removeable>
        </aspects>

    </config>

    <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>
                <form labelId="search.form.label.itproject" descriptionId="search.form.desc.itproject" id="dac_itprojects">cm:content</form>
            </forms>
        </advanced-search>
    </config>

    <!– dac:itproject aspect –>
    <config evaluator="model-type" condition="cm:content">
        <forms>
            <!– Search form –>
            <form id="dac_itprojects">
                <field-visibility>
                    <show id="dac:itproject-title" />
                    <show id="dac:itproject-department" />
                </field-visibility>
                <appearance>
                    <field id="dac:itproject-title" label-id="proj.itproject-title" >
                        <control template="/org/alfresco/components/form/controls/textfield.ftl"/>
                    </field>
                    <field id="dac:itproject-department" label-id="proj.itproject-department">
                        <control template="/org/alfresco/components/form/controls/selectmany.ftl">
                            <control-param name="options">Assessor,BOCC,Clerk,Community Development,County Manager,CRRUA,DASO,Detention Center,Facilities,Fire Marshal,Finance,Fleet,Flood,Health and Human Services,Human Resources,Information Technology,Legal,Office of Emergency Management,Roads,Treasurer,Utilities,External</control-param>
                            <control-param name="size">5</control-param>
                            <control-param name="mode">OR</control-param>
                        </control>
                    </field>
                </appearance>
            </form>
        </forms>
    </config>

    <config evaluator="aspect" condition="dac:itproject">
        <forms>
            <form>
                <field-visibility>
                    <show id="dac:itproject-title" />
                    <show id="dac:itproject-department" />
                    <show id="dac:itproject-owner" />
                    <show id="dac:itproject-itmanager" />
                    <show id="dac:itproject-inceptdate" />
                    <show id="dac:itproject-completedate" />
                </field-visibility>
                <appearance>
                    <field id="dac:itproject-title" label-id="proj.itproject-title" />
                    <field id="dac:itproject-department" label-id="proj.itproject-department">
                        <control template="/org/alfresco/components/form/controls/selectmany.ftl">
                            <control-param name="options">Assessor,BOCC,Clerk,Community Development,County Manager,CRRUA,DASO,Detention Center,Facilities,Fire Marshal,Finance,Fleet,Flood,Health and Human Services,Human Resources,Information Technology,Legal,Office of Emergency Management,Roads,Treasurer,Utilities,External</control-param>
                            <control-param name="size">5</control-param>
                        </control>
                    </field>
                    <field id="dac:itproject-owner" label-id="proj.itproject-owner">
                        <control template="/org/alfresco/components/form/controls/authority.ftl">
                            <control-param name="compactMode">false</control-param>
                        </control>
                    </field>
                    <field id="dac:itproject-itmanager" label-id="proj.itproject-itmanager">
                        <control template="/org/alfresco/components/form/controls/authority.ftl">
                            <control-param name="compactMode">false</control-param>
                        </control>
                    </field>
                    <field id="dac:itproject-inceptdate" label-id="proj.itproject-inceptdate" />
                    <field id="dac:itproject-completedate" label-id="proj.itproject-completedate" />
                </appearance>
            </form>
        </forms>
    </config>
</alfresco-config>
3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator
Issue is that you cannot configure aspect as form in alfresco share search. It has to be custom content type.If you search within forum you will find this issue faced by lot of peoples.

abruzzi
Champ on-the-rise
Champ on-the-rise
I did ask the question about having multiple forms for the same content type (cm:content) previously here and was told that by using separate IDs for the forms it would work. And that worked to create the separate form. (see attached images above) I haven't been able to test the search because of the lack of SOLR, but that still leaves the question of why the form works in one server instance and not in the other.  Both are running 4.2.1.

I guess I'll open a support ticket and see what they say.

abruzzi
Champ on-the-rise
Champ on-the-rise
I got a response from support and it is surprising and easy.  My advanced search config was conflicting with the RM module which was installed on my test server, but not the development code downloaded by maven.  That was causing the error, and to fix it I have to change the visibility to force=true like so:



    <config evaluator="model-type" condition="cm:content">
        <forms>
            <!– Search form –>
            <form id="dac_itprojects">
                <field-visibility>
                    <show id="dac:itproject-title" force="true" />
                    <show id="dac:itproject-department" force="true" />
                </field-visibility>
                <appearance>
                    <field id="dac:itproject-title" label-id="proj.itproject-title" >
                        <control template="/org/alfresco/components/form/controls/textfield.ftl"/>
                    </field>
                    <field id="dac:itproject-department" label-id="proj.itproject-department">
                        <control template="/org/alfresco/components/form/controls/selectmany.ftl">
                            <control-param name="options">Assessor,BOCC,Clerk,Community Development,County Manager,CRRUA,DASO,Detention Center,Facilities,Fire Marshal,Finance,Fleet,Flood,Health and Human Services,Human Resources,Information Technology,Legal,Office of Emergency Management,Roads,Treasurer,Utilities,External</control-param>
                            <control-param name="size">5</control-param>
                            <control-param name="mode">OR</control-param>
                        </control>
                    </field>
                </appearance>
            </form>
        </forms>
    </config>


This allowed the custom advanced search form to display properly, and search worked (though I'm having some unrelated other problems with this setup, specifically where my "options" in the above form have a space in the name like "Community Development" the last part at least "Development" is matching full text, not just the property).

Geof