Nishand's Blog

Welcome to my personal blog, All the information in this bogs is my ideas,findings and thoughts on .Net, Asp.Net and SharePoint.
ALL POSTING ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND

How to update Content Types through the Object Model?

When we add a field to the site content type SharePoint doesn't push-down those changes to the document library and the list level. The below code sample is for push-down all the changes to document libarary and the list level.The sample code from WSS 3.0 SDK doesn't seem to be working :) 

 

SPField field = spWeb.Fields[“YourNewField”]; //you can pick one from the site column collection for create a new one.

SPFieldLink fieldLink = new SPFieldLink(field);

SPContentType contentType = spWeb.ContentTypes[“Site Level Content Type”];

contentType.FieldLinks.Add(fieldLink);

contentType.Update(true);

Published Monday, May 21, 2007 12:34 AM by nishandv
Filed under:

Comments

No Comments
Anonymous comments are disabled

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker