Search code examples
xpagesxpages-extlib

How can I select conditionally some Documents (NotesXspViewEntry) in a dataView (xe:dataView or xe:dynamicViewPanel)


I need something like this for a time interval:

SELECT ( resDueDateBegin >= @Today) & (resDueDateEnd <@Adjust(@Today;0;1;0;0;0;0))

where resDueDateBegin and resDueDateEnd are a NotesDateTime object (item or Field).


Solution

  • It's good practice not to do date filtering in the select statement for the view itself.

    Instead you can use the ability to filter the view by a key (or a set of keys). In this case you then use a date range as the filter.

    First, make sure that your view is sorted by the two date fields. Then add your filter keys.

    The following shows a filter by a date range that I use to filter a view for a dynamic view panel to only show documents within a date range (of x days as specified by compositeData.limitDays) and to filter the view by a certain category (compositeData.catFilter).

    <xp:this.keys><![CDATA[#{javascript:
        try {
            var cal = java.util.Calendar.getInstance();
            cal.add(java.util.Calendar.DATE, compositeData.limitDays)
            var endDate = cal.getTime();
    
            cal.set(1970, 0, 1);
            var startDate = cal.getTime();
    
            var vDateRange = session.createDateRange(startDate, endDate);
    
            var v = new java.util.Vector();
            v.addElement(compositeData.catFilter);
            v.addElement(vDateRange);
            return v;                       
        }catch(e){
            print("view filter error: " + e.toString())
        }
    }]]></xp:this.keys>
    

    Using the above you should be able to make your filtering of two date columns work.