Archive

Archive for June, 2012

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();

Categories: SharePoint