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

Adding existing list columns in a document set using .net client object model

$
0
0

Hi,

I am not able to add existing columns in my library to the newly created document set using COM.

I am able create DS but want to add lib colunns in that DS. Pls refer below code:

                ContentTypeCollection conCollectionList = Mylib.ContentTypes;
                ClientContext.Load(conCollectionList);
                ClientContext.Load(conCollectionList, l => l.Include(t => t.Parent.Id, t => t.Fields.Include(p => p.InternalName)));

 //Adding DS id= 0x0120D520 to lib    

                 ContentType cTypeParent = ClientContext.Site.RootWeb.AvailableContentTypes.GetById("0x0120D520");

                var ctTYpeCreationInfo = new ContentTypeCreationInformation();
                ctTYpeCreationInfo.ParentContentType = cTypeParent;
                ctTYpeCreationInfo.Name = "New DS";
                ctTYpeCreationInfo.Group = "Document Set Content Types";
                ctTYpeCreationInfo.Description = "Document set Content Type";
                ContentType contentType = conCollectionList.Add(ctTYpeCreationInfo);            

                ClientContext.ExecuteQuery();

// Below code is not working to add field link to  DS and  getting "error: The content type has no children"

                var field = Mylib.Fields.GetByInternalNameOrTitle("Status");
                var fieldLink = new FieldLinkCreationInformation();
                fieldLink.Field = field;
                contentType.FieldLinks.Add(fieldLink);
              
                contentType.Update(true);
                ClientContext.ExecuteQuery();

Thanks in advance!


Viewing all articles
Browse latest Browse all 11571

Trending Articles



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