AnsweredAssumed Answered

Booleans and Constraints in Advanced Search

Question asked by riddellg on Sep 21, 2018

I have a custom type that I have configured in share-config-custom.xml for advanced search. I am having problems with two of the field types. 1) boolean  2) a text field which has constraints and some constraint values have spaces in them.

 

I believe the problem with the constraints field is that it gets sent in the query with extra " characters. If I hard code URLs without the extra quotes it works, but I cannot see how to make the advanced search form do this. For the boolean field I have no idea why it will not work, the objects in the database have got true/false values set but when including the boolean field set to "true" in the search it never succeeds, never get results.

 

I've seen other posts asking similar questions from a few years ago, reference to Jira tickets opened, so I'm hoping that these issues are known and solvable & I'm just not finding the answer anywhere.  I'm using Alfresco 5.2 Community Edition with the ALfresco 3 SDK All-in-one maven archetype.

 

My custom content model has a document type defined as follows:

 

<type name="lsBonds14:baseDocument">

<title>base document</title>

<parent>cm:content</parent>

<properties>

<property name="lsBonds14:docTypeCode">

<title>document type code</title>

<type>d:text</type>

<mandatory>true</mandatory>

<index enabled="true">

<tokenised>false</tokenised>

<facetable>false</facetable>

</index>

<constraints>

<constraint ref="lsBonds14:docTypeCodesOptions"/>

</constraints>

</property>

<property name="lsBonds14:purgeDate">

<title>purge date</title>

<type>d:date</type>

<mandatory>false</mandatory>

<index enabled="false">

<tokenised>false</tokenised>

</index>

</property>

<property name="lsBonds14:legalHoldIndicator">

<title>legal hold</title>

<type>d:boolean</type>

<mandatory>false</mandatory>

<index enabled="true">

<tokenised>false</tokenised>

</index>

</property>

<property name="lsBonds14:legalHoldCaseRef">

<title>legal hold case ref</title>

<type>d:text</type>

<mandatory>false</mandatory>

<index enabled="true">

<tokenised>false</tokenised>

</index>

</property>

 </properties>

<associations/>

<overrides/>

<mandatory-aspects/>

</type>

 

with the document type constraints as follows (note the spaces in some values):

<constraint name="lsBonds14:docTypeCodesOptions" type="LIST">

<parameter name="allowedValues">

<list>

<value></value>

<!-- Empty for default search-->

<value>AAAA</value>

<value>BBBB</value>

<value>CCCC</value>

<value>DDDD A EEEE</value>

<value>FFFF  GGGG  GGGGG  JJJJJ</value>

<value>KKKK   MMMMM</value>

<value>PPPPPPP</value>

<value>QQQQ  DE SSSSS</value>

<value>TTTT</value>

</list>

</parameter>

</constraint>

 

My search form is configured like this in share-config-custom.xml:

<form id="search">

<field-visibility>

<show id="cm:name"/>

<show id="lsBonds14:docTypeCode" force="true"/>

<show id="lsBonds14:purgeDate" force="true"/>

<show id="lsBonds14:legalHoldIndicator" force="true"/>

<show id="lsBonds14:legalHoldCaseRef" force="true" />

</field-visibility>

<appearance>

</appearance>

</form>

 

It looks fine, but the queries it is generating look like this and do not get hits on my data. (This is uuencoded in the generated URL, I've decoded it here) -

{"prop_cm_name":"","prop_lsBonds14_docTypeCode":"\"BBBB\"","prop_lsBonds14_purgeDate":"","prop_lsBonds14_legalHoldIndicator":"false","prop_lsBonds14_legalHoldCaseRef":"","datatype":"lsBonds14:baseDocument"}

 

If I hard code URLs this will work:  "prop_lsBonds14_docTypeCode":"BBBB"

as long as the boolean field is set to empty:   "prop_lsBonds14_legalHoldIndicator":""

 

Does anyone know the trick to getting booleans to work in Advanced Search?

Does anyone know the trick to getting non-single-word-constraints to work in Advanced Search?

 

 -gr

Outcomes