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>" +
| improve this question | | | | |

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.

| 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

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.