Robert
Robert

Reputation: 2691

C# Sharepoint cannot retrieve items from list programmatically

I have a list in sharepoint. I can retrieve this list but I cannot retrieve items from this list: enter image description here

My code looks lite this:

 using (var ctx = new ClientContext("http://sp2.intranet.mmmm.net/LWW/Europe/Warsaw/loc/eng/"))
            {

                Web web = ctx.Web;

                var tasksList = web.Lists.GetByTitle("IC-Portal-Announcements");

                CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<View><RowLimit>100</RowLimit></View>";

                ListItemCollection collListItem = tasksList.GetItems(camlQuery);

                ctx.Load(collListItem, items => items.Include(
                    item => item.Id,
                    item => item.DisplayName,
                    item => item.HasUniqueRoleAssignments
                    ));

                ctx.ExecuteQuery();

                foreach (ListItem oListItem in collListItem)
                {

                }

In oListItem I still see "IC-Portal-Announcements" in displayName, but I don't know how to get two tasks that are seen on the picture.

Upvotes: 0

Views: 451

Answers (1)

Tobias Mulzer
Tobias Mulzer

Reputation: 26

for starters you can try these queries:

var q1  = CamlQuery.CreateAllItemsQuery();
var viewfields = new string[] {"Id", "DisplayName", "HasUniqueRoleAssignments"};
var q2  = CamlQuery.CreateAllItemsQuery(1000, viewfields);

For the second one you can probably leave out your include statement on load I'm not sure if the names of the viewfields are correct. You could check with u2u caml query builder

For more specific information on caml search try this blog

Upvotes: 1

Related Questions