Xpages search display documents and responses

I am trying to filter a viewPanel using its property search

. ViewPanel has no categorized column.

These documents use the reader and author fields. One problem is that I am getting multiple blank lines in the views representing "hidden" documents.

All filter input fields are contained in the Doc. type as well as type of response.

var tmpArray = new Array("");
var cTerms = 0; 
var dateFormatter = new java.text.SimpleDateFormat( "MM-dd-yyyy" ); 

if (sessionScope.compA) { 
tmpArray[cTerms++] = "(Field Comp = \"*" + sessionScope.compA + "*\")"; 
tmpArray[cTerms++] = "(Field Compania = \"*" + sessionScope.compA + "*\")"; 
/* Comp - the field from Doc. & Compania - the field from Response */
} 

if (sessionScope.numePro) { 
tmpArray[cTerms++] = "(Field NumeProiect = \"*" + sessionScope.numePro + "*\")"; 
tmpArray[cTerms++] = "(Field Proiect = \"*" + sessionScope.numePro + "*\")"; 
/* NumeProiect - the field from Doc. & Proiect - the field from Response */
} 
if (sessionScope.din && sessionScope.pana) {
    tmpArray[cTerms++] = "Field _creationDate >= " + dateFormatter.format(sessionScope.din) + " AND Field _creationDate <= " + dateFormatter.format(sessionScope.pana);
}      
qstring = tmpArray.join(" OR ").trim(); 
sessionScope.queryString = qstring; 
return qstring

      

But I don't get the expected results, I get something like: correct docs for sessionScope.compA, but if I add a value for the second Scope.numePro session that is not contained in any of the docs listed in the view, the results are the same and the result is must not be.

How can I achieve this?

+3


source to share


1 answer


I assume you just messed up the logical connection between the ftsearch parts. The following code should work for you:



var tmpArray = new Array("");
var cTerms = 0; 
var dateFormatter = new java.text.SimpleDateFormat( "MM-dd-yyyy" ); 

if (sessionScope.compA) { 
    tmpArray[cTerms++] = "((Field Comp = \"*" + sessionScope.compA + "*\") OR " + 
                          "(Field Compania = \"*" + sessionScope.compA + "*\"))"; 
    /* Comp - the field from Doc. & Compania - the field from Response */
} 

if (sessionScope.numePro) { 
    tmpArray[cTerms++] = "((Field NumeProiect = \"*" + sessionScope.numePro + "*\") OR " + 
                          "(Field Proiect = \"*" + sessionScope.numePro + "*\"))"; 
    /* NumeProiect - the field from Doc. & Proiect - the field from Response */
} 
if (sessionScope.din && sessionScope.pana) {
    tmpArray[cTerms++] = "Field _creationDate >= " + dateFormatter.format(sessionScope.din) + 
    " AND Field _creationDate <= " + dateFormatter.format(sessionScope.pana);
}      
qstring = tmpArray.join(" AND ").trim(); 
sessionScope.queryString = qstring; 
return qstring

      

+1


source







All Articles