4

i am trying to enable versioning on a ducument library using the client object model my code currently is as follows when i create the document library.

            ClientContext clientContext = getClientContext();
        try
        {
            Web web = clientContext.Web;
            ListCollection listCol = web.Lists;
            ListCreationInformation lci = new ListCreationInformation();
            lci.Title = DocLib;
            lci.TemplateType = (int)ListTemplateType.DocumentLibrary;
            List documentLibrary = listCol.Add(lci);
            documentLibrary.EnableVersioning = true;
            documentLibrary.EnableMinorVersions = true;
            documentLibrary.ContentTypesEnabled = true;
            clientContext.Load(listCol);
            clientContext.ExecuteQuery();
            Console.WriteLine("doclibCreated created");
            return documentLibrary;
        }
        catch (Microsoft.SharePoint.Client.ServerException e)
        {
            Console.WriteLine(e.Message);
            return null;
        }

but these settings are not persisted

4

You need to call Update() to apply document library properties:

.
.
documentLibrary.ContentTypesEnabled = true;

documentLibrary.Update();   <---- ADDED

clientContext.Load(listCol);
.
.

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.