Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Trying to add IsNotNull parameter and ViewFields paramter but throwing an error. Am I inserting incorrectly or missing something to make sure this executes correctly? Seems like View is bring back all of the items in the list and just need the item I was original returning before needing to add these other parameter

                       SPQuery myquery = new SPQuery();
                        myquery.Query =
                        "<View>" +
                            "<Where>" +
                            "<And>" +
                                "<Contains>" +
                                    "<FieldRef Name='Group' />" +
                                    "<Value Type='Text'>City</Value>" +                                  
                                "</Contains>" +
                                "<Eq>" +
                                    "<FieldRef Name='System' />" +
                                    "<Value Type='Text'>" + Param.var.ToString() + "</Value>" +
                                "</Eq>" +
                                "<And>" +
                                "<IsNotNull>" +
                                    "<FieldRef Name='Email' />" +
                                "</IsNotNull>" + 
                                "</And>" +
                                "<ViewFields>" +
                                    "<FieldRef Name='Email' />" +
                                "</ViewFields>" +
                            "</And>" +
                            "</Where>" +
                        "</View>";
share|improve this question

1 Answer 1

up vote 3 down vote accepted

You don't use ViewFields inside the Where clause in a CAML query. See Query Schema and SPQuery.ViewFields Property

Also, the And around the IsNotNull node is doing nothing. The And needs two child elements to operate correctly.

share|improve this answer
    
gotcha! that did the trick for the ViewFields. I didn't know about the IsNotNull, I tink I can figure that one out shortly. Thanks! –  nholloway4 Aug 8 '12 at 18:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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