Programmatically create SiteColumn for a Web in SharePoint using Client Object Model

string siteUrl = "http://servername/";
SP.ClientContext ctx = new SP.ClientContext(siteUrl);
this.ctx.Load(this.ctx.Web);
SP.Web web = this.ctx.Web;

web.Fields.AddFieldAsXml(schemaXML, false, SP.AddFieldOptions.AddFieldToDefaultView);

web.Update();
SP.FieldCollection fieldCollection = web.AvailableFields;
ctx.Load(fieldCollection);
ctx.ExecuteQuery();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s