1

This works

"<Where>" +
    "<And>" +
        "<Geq>" +
            "<FieldRef Name=\"StartDate\"/>" +
            "<Value Type=\"Date\">" +
                DateTime.Now.Date.FirstBusinessDayOfWeek().ToString("yyyy-MM-ddTHH:mm:ssZ") + 
            "</Value>" +
        "</Geq>" +
        "<Leq>" +
            "<FieldRef Name=\"DueDate\"/>" +
            "<Value Type=\"Date\">" +
                DateTime.Now.Date.LastBusinessDayOfWeek().ToString("yyyy-MM-ddTHH:mm:ssZ") + 
            "</Value>" +
        "</Leq>" +
    "</And>" +
"</Where>"

This does not

"<Where>" +
    "<And>" +
        "<Geq>" +
            "<FieldRef Name=\"StartDate\"/>" +
            "<Value Type=\"Date\">" +
                DateTime.Now.Date.FirstBusinessDayOfWeek().ToString("yyyy-MM-ddTHH:mm:ssZ") + 
            "</Value>" +
        "</Geq>" +
        "<Leq>" +
            "<FieldRef Name=\"DueDate\"/>" +
            "<Value Type=\"Date\">" +
                DateTime.Now.Date.LastBusinessDayOfWeek().ToString("yyyy-MM-ddTHH:mm:ssZ") + 
            "</Value>" +
        "</Leq>" +
        "<Eq>" +
            "<FieldRef Name=\"MasterTaskID\"/>" +
            "<Value Type=\"Text\">" +
            "t4" + 
            "</Value>" +
        "</Eq>" +
    "</And>" +
"</Where>"

Including the filter criteria for MasterTaskID results in a SOAP exception being thrown.

Can anyone spot what is wrong with this query?

0

Try below query.

If you're not familiar with CAML, you could use caml designer to help you building the caml query.

"<Where>" +
    "<And>" +
    "<And>" +
        "<Geq>" +
            "<FieldRef Name=\"StartDate\"/>" +
            "<Value Type=\"Date\">" +
                DateTime.Now.Date.FirstBusinessDayOfWeek().ToString("yyyy-MM-ddTHH:mm:ssZ") + 
            "</Value>" +
        "</Geq>" +
        "<Leq>" +
            "<FieldRef Name=\"DueDate\"/>" +
            "<Value Type=\"Date\">" +
                DateTime.Now.Date.LastBusinessDayOfWeek().ToString("yyyy-MM-ddTHH:mm:ssZ") + 
            "</Value>" +
        "</Leq>" +
    "</And>" +  
        "<Eq>" +
            "<FieldRef Name=\"MasterTaskID\"/>" +
            "<Value Type=\"Text\">" +
            "t4" + 
            "</Value>" +
        "</Eq>" +
    "</And>" +
"</Where>"
  • Thanks Lee! I'll check out the caml designer, I am somewhat new to caml. I need a facepalm emoji – user80394 Dec 17 '18 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.