Home > SharePoint > Creating a Publishing HTML field in SharePoint programmatically

Creating a Publishing HTML field in SharePoint programmatically

Sooooooo, creating a Publishing HTML field in SharePoint (think wiki Page Content field) is a huge pain (well, the solution is easy, but the figuring it out part was a pain).  However, because I’m extremely busy, I’m going to skip the part where I explain all the hundreds of things I’ve tried and why they all failed, and move straight to the solution:

PowerShell

$web = Get-SPWeb “http://dev01”;
$spList = $web.Lists[“Pages”];
$newField = “<Field Type=’HTML’ DisplayName=’FieldName’ RichText=’TRUE’ RichTextMode=’FullHtml’ />”;
$spList.Fields.AddFieldAsXML($HTMLFieldXML);
$spList.Update();

Advertisements
Categories: SharePoint
  1. No comments yet.
  1. No trackbacks yet.

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

%d bloggers like this: