Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

So why can't I just get back the items I want, why am I getting back all the items in the list?

$
0
0

So this is kinda odd, but I have no idea why it isn't working. The idea is to get back items that the next review date = today, however, I am getting back all the items in the list.

I really have no idea what is going on here

anyway, the code:

 int count = 0;

            ClientContext clientContext = new ClientContext("https://SharePointSite/sites/Someplace");
            Web oWebsite = clientContext.Web;
            ListCollection collList = oWebsite.Lists;

            List oList = collList.GetByTitle("My List Name");
            DateTime startDate = DateTime.Now;
            string startDateFx = startDate.ToString("yyyy-MM-ddTHH:mm:ssZ");

            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<Query><Where><FieldRef Name='Next_x0020_Review_x0020_Date' /><Value Type='DateTime'>"+ startDateFx  + "</Value></Where></Query>";

            Microsoft.SharePoint.Client.ListItemCollection collListItem = oList.GetItems(camlQuery);

            clientContext.Load(collListItem, items => items.Include(item => item["Next_x0020_Review_x0020_Date"]));

            clientContext.ExecuteQuery();

            foreach (Microsoft.SharePoint.Client.ListItem oListItem in collListItem)
            {
                Console.WriteLine("Next review date: {0} ", oListItem["Next_x0020_Review_x0020_Date"]);

                count = count + 1;


            }
            Console.WriteLine(count);
            Console.ReadKey();
Anything would be great.

Best regards, Mike


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>