add a <AND><Eq>...</Eq></And> when I use DateRangeOverlap

Apr 22, 2015 at 6:37 PM
Hi Guys

I am trying to query a calendar list with receurrence event so I am using the camlQuery below. My problem is that I want to get only event for a specific user. I added <Eq><FieldRef Name=\"User\" LookupId=\"true\" /><Value Type=\"Integer\">[Valuehere]</Value></Eq> but the query does not return anything. So How can I add more conditions to the where part if I use DateRangesOverlap?

"<Query>"+
                                            "<Where>"+
                                                    "<DateRangesOverlap>"+
                                                      "<FieldRef Name='EventDate' /><FieldRef Name='EndDate' />"+
                                                       "<FieldRef Name='RecurrenceID' /><Value Type='DateTime'>" + HelperSrv.getCalendarView(viewType) + "</Value>"+
                                                    "</DateRangesOverlap>"+
                                                    /*"<And>"+
                                                       "<Eq><FieldRef Name=\"User\" LookupId=\"true\" /><Value Type=\"Integer\">" + "63" + "</Value></Eq>"+    
                                                    "</And>"+*/
                                            "</Where>"+
                                            "<OrderBy>"+
                                                "<FieldRef Name='EventDate' />"+
                                            "</OrderBy>"+
                                     "</Query>";
Apr 22, 2015 at 7:09 PM
Edited Apr 22, 2015 at 7:14 PM
The CAML "<And>" operator needs to be wrapped around the two conditions. At present, you're only wrapping one condition. Try something like...
"<Query>" +
    "<Where>" +
        "<And>" +
            "<DateRangesOverlap>" +
                "<FieldRef Name='EventDate' /><FieldRef Name='EndDate' />" +
                "<FieldRef Name='RecurrenceID' /><Value Type='DateTime'>" + HelperSrv.getCalendarView(viewType) + "</Value>" +
            "</DateRangesOverlap>" +
            "<Eq><FieldRef Name='User' LookupId='true' /><Value Type='Integer'>" + 63 + "</Value></Eq>" +
        "</And>" +
    "</Where>" +
    "<OrderBy>" +
        "<FieldRef Name='EventDate' />" +
    "</OrderBy>" +
"</Query>"
Also, I don't think you're going to return anything looing for a "User" field unless you've created a people picker field with a static name of "User." Are you looking for whomever created the calendar item? That is "Author." If you're looking for the Modified By, that is "Editor."
Geoff