habiba kessraoui
habiba kessraoui

Reputation: 9

xpages + Search in a view panel between 2 dates

I have a view with some data, and a column with the creation date of each document. I want to make a search feature with 3 input fields: ip_address, StartDate, EndDate. The result of the search should be all the documents with the same ip_addressand within the 2 dates.

I use this link Xpages search between 2 dates

but it return me this error

Unexpected runtime error:The runtime has encountered an unexpected error.

com.ibm.xsp.FacesExceptionEx: Notes error: Relational operators are not supported in text fields Notes error: Relational operators are not supported in text fields enter image description here

this is the code of the search query:

        var search = "";
        var formatter = new java.text.SimpleDateFormat("dd/MM/yyyy");

        if (viewScope.StartDate) {
            search += ' AND [imp_dateTrace] >=' + formatter.format(viewScope.StartDate);
        }

        if (viewScope.EndDate) {
            search += ' AND [imp_dateTrace] <=' + formatter.format(viewScope.EndDate);
        }

        if (viewScope.imp) {
            search += ' AND [imp_IP]="' + viewScope.imp + '"';
        }
        if (viewScope.agence) {
            search += ' AND [imp_emplacement]="' + viewScope.agence + '"';
        }

        viewScope.searchquery = search;
        return viewScope.searchquery.substring(5);

Upvotes: 1

Views: 593

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30960

You don't use [_creationDate] like showed in this answer but your own field imp_dateTrace.

If field imp_dateTrace contains just document's creation date then use [_creationDate] instead. [_creationDate] will work as you don't depend on field types in documents.

If you have to use field imp_dateTrace then make sure your field is stored as a date field in documents.

If that is the case then database's UNK table might list this field as a text field. This can happen if it was first created as a text field and later got changed to a date field. You would have to fix the UNK table in this case:

  • delete FT-index
  • compact database with option -c (copy-style)
  • create new FT-index.

Make also sure your query doesn't start with " AND ". This would be the case with your code shown in your question.

Upvotes: 0

Related Questions