Question

I have a Library, which stores document sets (the content type here is a documentset which contains more than one word document). Currently I can to get the items from the library using the below code

CamlQuery q = new CamlQuery();
var items = list.GetItems(q);
clientccontext.Load(items);
clientccontext.ExecuteQuery();

Which is giving the document sets properly. Now how can I get access to the word document files contained in each document set returned from the above code. I am using client object model. Thanks.

Was it helpful?

Solution

A document set is a special sort of folder. The items in the document set can be retrieved as you would in a 'regular' folder. Enumerate through the items returned in the success function and call get_file() on the item.

OTHER TIPS

The following code worked-(check the comments in the code)

    CamlQuery q = new CamlQuery();
    q.ViewXml = @"<View Scope='Recursive'>
                            <Query>
                            </Query>
                        </View>";
    // This line did the trick!!! - "Test" is actually the name of document set I am trying to access
    q.FolderServerRelativeUrl = "/demo/Doc/Test";
    var returnlist = new List<string>();
    var items = list.GetItems(q);
    cc.Load(items);
    cc.ExecuteQuery();
    foreach (var item in items)
    {
        //Now I can retrieve the files inside document set like this..
        var fileName = item.FieldValues["FileLeafRef"].ToString();

        returnlist.Add(fileName);
    }

Flowerking,

The more generic way of accomplishing what you want is to design the view through the web interface, and then inspect the resulting view XML, either through code or through a tool such as SharePoint Manager (http://spm.codeplex.com/).

This process will allow you to greatly speed up creating the view XML (because you do so through the web interface and verify that it is correct there) and it will give you all the options, not just filtering by content type.

You can view the outline of the process (although not explicitly for views) in a webcast I recorded for SP Saturday DC back in 2009. The method is still the same.

http://vimeo.com/4340994

.b

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top